2015-11-03 53 views
0

輸出:未定義參照 'owr_init'(連接器錯誤)使所有的

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 

我已經構建了OpenWebRTC,正如位於Debian 8上的wiki所述,並安裝了生成的.deb文件。在Eclipse中,我包含了頭文件(/opt/openwebrtc-0.3/include)和libs(/opt/openwebrtc-0.3/lib),它仍然不起作用。我還上傳生成的deb文件到我的apt repository

的sources.list:

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

你能找到文件'libopenwebrtc.la'嗎? – mic4ael

+0

是,/opt/openwebrtc-0.3/lib/libopenwebrtc.la –

回答

1

試圖改變

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 

的問題可能是你沒有鏈接必要的庫。

相關問題