gcc命令:
g++ xx.o xy.o -o xx -fPIC -O3 -std=c++0x `python3-config --includes` -I`readlink -f ..` -I ./anaconda3.8.3/include -DGADABIN -lm -lboost_program_options -lboost_iostreams -L ./anaconda3.8.3/lib
编译报错:
ld: warning: librt.so.1, needed by ./anaconda3.8.3/lib/libboost_program_options.so, not found (try using -rpath or -rpath-link)
ld: warning: libpthread.so.0, needed by ./anaconda3.8.3/lib/libboost_iostreams.so, not found (try using -rpath or -rpath-link)
ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `pthread_condattr_setclock@GLIBC_2.3.3'
ld: ./anaconda3.8.3/lib/./libzstd.so.1: undefined reference to `pthread_join@GLIBC_2.2.5'
ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `clock_gettime@GLIBC_2.2.5'
ld: ./anaconda3.8.3/lib/./liblzma.so.5: undefined reference to `pthread_sigmask@GLIBC_2.2.5'
ld: ./anaconda3.8.3/lib/./libzstd.so.1: undefined reference to `pthread_create@GLIBC_2.2.5'
解决方法:
在编译命令中加上-lpthread -lbrt
,即:
g++ xx.o xy.o -o xx -fPIC -O3 -std=c++0x `python3-config --includes` -I`readlink -f ..` -I ./anaconda3.8.3/include -DGADABIN -lm -lboost_program_options -lboost_iostreams -lpthread -lbrt -L ./anaconda3.8.3/lib
参考:
网友评论