我只是按照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使用boost.python。谢谢
发布于 2019-11-14 20:56:13
这是一个链接器错误。可能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
它帮助我解决了这个错误。
https://stackoverflow.com/questions/55578394
复制相似问题