gpt4 book ai didi

c - 对 'owr_init' 的 undefined reference (链接器错误)

转载 作者:行者123 更新时间:2023-11-30 15:15:37 25 4
gpt4 key购买 nike

make all 的输出:

make all 
Building file: ../webrtc.c
Invoking: Cross GCC Compiler
gcc -std=c99 -I/opt/openwebrtc-0.3/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"webrtc.d" -MT"webrtc.o" -o "webrtc.o" "../webrtc.c"
Finished building: ../webrtc.c

Building target: WebRTC
Invoking: Cross GCC Linker
gcc ./webrtc.o -lglib-2.0 -lsctp -o "WebRTC" -L/opt/openwebrtc-0.3/lib -L/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/include/glib-2.0
./webrtc.o: In function `startServer':
/home/sn/workspace/cpp/praktikum/WebRTC/Debug/../webrtc.c:17: undefined reference to `owr_init'
/home/sn/workspace/cpp/praktikum/WebRTC/Debug/../webrtc.c:18: undefined reference to `owr_run_in_background'
collect2: error: ld returned 1 exit status
makefile:32: recipe for target 'WebRTC' failed
make: *** [WebRTC] Error 1

webrtc.c:

#include "webrtc.h"
int main(void)
{
/*startClient();*/
startServer();
return EXIT_SUCCESS;
}
void startServer(void)
{
printf("Initializing OpenWebRTC");
owr_init(NULL);
owr_run_in_background();
}

webrtc.h:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <pthread.h>

#include <owr/owr.h>
#include <owr/owr_data_channel.h>
#include <owr/owr_crypto_utils.h>
#include <owr/owr_types.h>
/* Defines:*/
#define MAX_BUFFER 1024

#define SERVER_PORT_NUMBER 65300
#define SERVER_BIND_ADDR "127.0.0.1"

/* Prototypes: */
void startServer(void);

文件输出:

libopenwebrtc.so.4201.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=3a9726e870736687b14c1dca326bda336fb2d088, stripped

我已经按照位于 here 的 wiki 中所述构建了 OpenWebRTC在 Debian 8 上并安装生成的 .deb 文件。在 Eclipse 中,我已经包含了头文件 (/opt/openwebrtc-0.3/include) 和库 (/opt/openwebrtc-0.3/lib),但它仍然无法工作。我还将生成的 deb 文件上传到我的 apt repository

来源.列表:

deb http://openwebrtc.niehus.eu/apt/debian/ jessie main

最佳答案

尝试改变

gcc  ./webrtc.o   -lglib-2.0 -lsctp -o  "WebRTC" -L/opt/openwebrtc-0.3/lib -L/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/include/glib-2.0

gcc  ./webrtc.o   -lglib-2.0 -lsctp -lopenwebrtc -o  "WebRTC" -L/opt/openwebrtc-0.3/lib -L/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/include/glib-2.0

问题可能是您没有链接必要的库。

关于c - 对 'owr_init' 的 undefined reference (链接器错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33501910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com