【问题标题】:How to fix /usr/bin/ld: cannot find -lboost_python如何修复 /usr/bin/ld:找不到 -lboost_python
【发布时间】:2019-04-08 17:05:41
【问题描述】:

我刚刚按照https://www.boost.org/doc/libs/1_69_0/libs/python/doc/html/building/no_install_quickstart.html 上的说明安装了 boost.python 但是当我尝试运行代码时

    bjam toolset=gcc --verbose-test test 

它抛出:

...found 23 targets...
...updating 6 targets...
gcc.link.dll extending.so
/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status

    "g++"    -o "extending.so" -Wl,-h -Wl,extending.so -shared -Wl,--start-group "extending.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lboost_python -ldl -lpthread -lutil -Wl,--end-group -fPIC -g 

...failed gcc.link.dll extending.so...
...skipped <p.>test_ext for lack of <p.>extending.so...
gcc.link test_embed
/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status

    "g++" -L"/usr/lib" -L"/usr/lib/python2.7/config" -Wl,-rpath -Wl,"/usr/lib" -Wl,-rpath -Wl,"/usr/lib/python2.7/config"  -o "test_embed" -Wl,--start-group "embedding.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lboost_python -ldl -lpthread -lutil -lpython2.7 -Wl,--end-group -fPIC -g 

...failed gcc.link test_embed...
...skipped <p.>test_embed.run for lack of <p.>test_embed...
...failed updating 2 targets...
...skipped 4 targets...

有人知道怎么解决吗?我只想提升使用 boost.python。 谢谢

【问题讨论】:

    标签: g++ ubuntu-16.04 boost-python bjam


    【解决方案1】:

    这是一个链接器错误。可能 lib 文件使用不同的名称,因此必须手动创建符号链接。

    在usr/lib目录下查找“libboost_pythonXX.so”文件

    XX 将匹配你在构建时配置 boost 的 python 版本,从抛出的异常来看你可能用 python2.7 配置它,所以文件可能会被命名为 libboost_python27.so

    然后创建一个符号链接:

    sudo ln -s "libboost_pythonXX.so" libboost_python.so

    您可以使用此链接作为参考。

    https://github.com/BVLC/caffe/issues/4843

    它帮我解决了错误。

    【讨论】:

      猜你喜欢
      • 2020-05-17
      • 2021-05-07
      • 2011-07-16
      • 2012-05-17
      • 2020-04-14
      • 2012-03-26
      • 2018-12-13
      • 2015-09-22
      • 2020-01-19
      相关资源
      最近更新 更多