简体   繁体   English

Makefile“未定义参考”错误

[英]Makefile 'undefined reference' error

I am working on an IRC-Bot and I am at the point of running 'make' on a bot that is already finished and I want to possibly modify. 我正在IRC-Bot上工作,现在我要在已经完成的机器人上运行“ make”,并且可能要进行修改。 However, I get the following 'undefined reference' error: 但是,出现以下“未定义引用”错误:

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

I don't know if I need to show the Makefile here, since it is pretty long. 我不知道是否需要在此处显示Makefile,因为它很长。 I have searched for this error already but I couldnt really find anything that could help me resolve this error and I was hoping to find some individual help here. 我已经搜索了此错误,但是我真的找不到能帮助我解决该错误的任何东西,我希望在这里找到一些个人帮助。 Thanks! 谢谢!

edit: ./configure output: 编辑:./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

Your platform's documentation should specify how to correctly get POSIX pthreads support. 平台的文档应指定如何正确获得POSIX pthreads支持。 For most Linux distributions, you pass the -pthread flag to both the compiler and the linker. 对于大多数Linux发行版,您将-pthread标志传递给编译器和链接器。 Typically, the compiler flag does nothing but the linker flag links to the pthreads library. 通常,编译器标志什么都不做,但链接器标志链接到pthreads库。

Do not use -lpthread . 不要使用-lpthread It's not portable, and in the future more than just linking to the library might be needed. 它不是可移植的,将来可能不仅需要链接到库。 For example, passing -DTHREAD_SAFE to the compiler might be required on some platforms. 例如,在某些平台上,可能需要将-DTHREAD_SAFE传递给编译器。

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

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