我在一个IRC-Bot上工作,我在一个已经完成的机器人上运行'make‘,我想可能会修改。然而,我得到了下面的'undefined reference‘错误:
g++ -g -O2 -lpthread -o markovsky-irc markovsky.o markovutil.o markovsky-irc.o botnet.o dcc_chat.o dcc_send.o output.o server.o utils.o
botnet.o: In function `BN_getthreadspecific':
/home/bavor/Applications/markovsky-0.53/botnet/botnet.c:113: undefined reference to `pthread_once'
/home/bavor/Applications/markovsky-0.53/botnet/botnet.c:114: undefined reference to `pthread_getspecific'
/home/bavor/Applications/markovsky-0.53/botnet/botnet.c:119: undefined reference to `pthread_setspecific'
botnet.o: In function `BN_Connect':
/home/bavor/Applications/markovsky-0.53/botnet/botnet.c:154: undefined reference to `pthread_create'
botnet.o: In function `BN_tsinitkey':
/home/bavor/Applications/markovsky-0.53/botnet/botnet.c:95: undefined reference to `pthread_key_create'
dcc_chat.o: In function `BN_AcceptDCCChat':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_chat.c:216: undefined reference to `pthread_create'
dcc_chat.o: In function `BN_SendDCCChatRequest':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_chat.c:97: undefined reference to `pthread_create'
dcc_chat.o: In function `BN_AcceptDCCChat':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_chat.c:217: undefined reference to `pthread_detach'
dcc_chat.o: In function `BN_SendDCCChatRequest':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_chat.c:98: undefined reference to `pthread_detach'
dcc_send.o: In function `BN_SendDCCSendRequest':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_send.c:102: undefined reference to `pthread_create'
dcc_send.o: In function `BN_AcceptDCCSend':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_send.c:245: undefined reference to `pthread_create'
dcc_send.o: In function `BN_SendDCCSendRequest':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_send.c:103: undefined reference to `pthread_detach'
dcc_send.o: In function `BN_AcceptDCCSend':
/home/bavor/Applications/markovsky-0.53/botnet/dcc_send.c:246: undefined reference to `pthread_detach'
utils.o: In function `BN_UnsetSigs':
/home/bavor/Applications/markovsky-0.53/botnet/utils.c:257: undefined reference to `pthread_sigmask'
collect2: error: ld returned 1 exit status
make: *** [markovsky-irc] Error 1我不知道是否需要在这里显示Makefile,因为它太长了。我已经搜索了这个错误,但是我真的找不到任何可以帮助我解决这个错误的东西,我希望在这里找到一些个人的帮助。谢谢!
编辑:./configure输出:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands发布于 2014-04-14 06:38:00
您的平台文档应该指定如何正确地获得POSIX pthread支持。对于大多数Linux发行版,将-pthread标志同时传递给编译器和链接器。通常,编译器标志什么也不做,但链接器标志链接到pthread库。
请勿使用-lpthread。它不是可移植的,将来可能需要的不仅仅是链接到库。例如,在某些平台上可能需要将-DTHREAD_SAFE传递给编译器。
https://stackoverflow.com/questions/23047103
复制相似问题