【问题标题】:Boost 1.51 : "error: could not link against boost_thread !"Boost 1.51:“错误:无法链接到 boost_thread!”
【发布时间】:2012-09-06 16:14:44
【问题描述】:

为袖扣安装 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 ! 

【问题讨论】:

  • 你真的安装了 Boost 库吗?您的操作系统是什么,您是如何安装 boost 的哪些部分的?
  • 我使用该链接中的说明安装了 boost。我在 64 位 CentOS 上。我安装了需要构建的头文件和库,并使用 --with-boost=/path/to/boost 指定了 ./configure 的安装路径
  • 什么是/path/to/boost?是<YOUR_BOOST_INSTALL_DIRECTORY>(prefix=的那个)还是boost代码本身的位置?
  • 这是 boost 安装的位置。所以它有头文件和编译的库。

标签: boost configure


【解决方案1】:

检查您的 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"

【讨论】:

    猜你喜欢
    • 2011-03-03
    • 2011-10-18
    • 2017-05-15
    • 2011-10-01
    • 2014-06-02
    • 2023-03-26
    • 2015-02-13
    • 1970-01-01
    相关资源
    最近更新 更多