提升1.51:“错误:无法链接到boost_thread!”

时间:2012-09-13 14:27:03

标签: boost configure

在我为袖扣安装了boost之后,我运行了./configure。我收到以下错误:

checking for exit in -lboost_thread... no
checking for exit in -lboost_thread... (cached) no
checking for exit in -lboost_thread... (cached) no
error: Could not link against boost_thread ! 

1 个答案:

答案 0 :(得分:0)

检查你的config.log,它会更详细地告诉你失败的原因:

configure:11032: checking for exit in -lboost_thread
configure:11057: g++ -o conftest -I/home/jcomeau/include  -Wstack-protector -fstack-protector-all -fPIE  -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  -L/home/jcomeau/lib  -Wl,-z,relro -Wl,-z,now -pie -L/home/jcomeau/lib conftest.cpp -lboost_thread  -lminiupnpc -lminiupnpc -lminiupnpc -lminiupnpc  >&5
/usr/bin/ld: warning: libboost_system.so.1.54.0, needed by /home/jcomeau/lib/libboost_thread.so, not found (try using -rpath or -rpath-link)
/home/jcomeau/lib/libboost_thread.so: undefined reference to `boost::system::system_category()'
/home/jcomeau/lib/libboost_thread.so: undefined reference to `boost::system::generic_category()'
collect2: error: ld returned 1 exit status
configure:11057: $? = 1

在这种情况下,我不得不改变我的./configure命令:

./configure CXXFLAGS="-I$HOME/include" LDFLAGS="-L$HOME/lib"  --prefix=$HOME --with-boost-libdir=$HOME/lib

为:

./configure CXXFLAGS="-I$HOME/include" LDFLAGS="-L$HOME/lib -Wl,-rpath-link,$HOME/lib" --with-boost-libdir=$HOME/lib --prefix=$HOME

根据此处的建议:Get rid of "gcc - /usr/bin/ld: warning lib not found"