[英]Trouble linking with boost.python and python3
當我嘗試在Win10的Visual Studio 2017中編譯boost.python'Hello World'程序時,遇到以下鏈接錯誤:
LNK1104 cannot open file 'boost_python-vc141-mt-1_64.lib'
但是,我想與python3版本鏈接。 我使用此命令構建了boost.python庫
b2 --with-python variant=release link=shared address-model=64
using python : 3.6 ;
在我的project-config.jam文件中
boost_python3-vc141-mt-1_64.dll
和boost_python3-vc141-mt-1_64.lib
我不知道為什么我的項目嘗試與python2版本鏈接。 我從未在任何地方指定要鏈接的boost.python庫,也不知道在哪里更改它。
如果重要的話,這是我嘗試編譯的C ++程序(轉換為x64 .dll)
#include <boost/python.hpp>
char const* greet() {
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext) {
using namespace boost::python;
def("greet", greet);
}
以我的經驗,在Windows / VC ++上,Boost.Python的自動鏈接總是搜索boost_python-vc<blah-blah-blah>.lib
而不管Python版本如何。 在針對Python 3進行構建時,b2實際上會生成2組lib文件: boost_python-vc...
和boost_python3-vc...
它們是相同的,只是名稱不同。 因此,如果您沒有boost_python-vc141-mt-1_64.lib
文件,請通過刪除3
重命名您的boost_python3-vc141-mt-1_64
lib和dll文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.