简体   繁体   English

未定义对“ owr_init”的引用(链接器错误)

[英]Undefined reference to 'owr_init' (linker error)

Output of 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: 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: 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);

Output of file: 文件输出:

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

I've build OpenWebRTC as stated in the wiki located here on Debian 8 and installed the generated .deb files. 我已经建立OpenWebRTC在位于维基说这里在Debian 8和安装所产生的.deb文件。 In Eclipse I've included the header files (/opt/openwebrtc-0.3/include) and the libs (/opt/openwebrtc-0.3/lib) and it is still not working. 在Eclipse中,我包含了头文件(/opt/openwebrtc-0.3/include)和库文件(/opt/openwebrtc-0.3/lib),但仍然无法正常工作。 I've also uploaded the generated deb files into my apt repository 我还将生成的deb文件上传到了apt仓库中

sources.list: sources.list:

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

Try to change 尝试改变

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

to

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

The problem might be that you are not linking necessary library. 问题可能是您没有链接必要的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM