未定义对 'owr_init' 的引用(链接器错误)
Undefined reference to 'owr_init' (linker error)
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 on Debian 8 and installed the generated .deb files. 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. I've also uploaded the generated deb files into my apt repository
的 wiki 中的说明构建了 OpenWebRTC
sources.list:
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
问题可能是您没有链接必要的库。
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 on Debian 8 and installed the generated .deb files. 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. I've also uploaded the generated deb files into my apt repository
的 wiki 中的说明构建了 OpenWebRTCsources.list:
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
问题可能是您没有链接必要的库。