如何在 VS2017 中使用 Boost Python 库构建
How to Build Using the Boost Python Libraries in VS2017
我使用 MS Visual Studio Professional 2017 和 32 位 Python 3.4 构建了 Boost 1.64.0 Python 库。现在,当我针对生成的库编写应用程序时,出现以下 link 错误:
LINK : fatal error LNK1104: cannot open file 'libboost_python-vc141-mt-1_64.lib'
我查看了 stage/lib 目录,确实,库名为 libboost_python3 -vc141-mt-1_64.lib(注意名称中的3)。我假设 3 引用了 Boost Python 库是使用 Python 生成的事实 3. 为什么构建的库与我的项目尝试的库之间存在命名不一致导入?仅仅是我的项目配置中缺少宏定义吗?
在 MSVC 构建中,boost
headers 使用 MSVC #pragma comments 到 autolink
到 boost
库,请参阅 boost/config/auto_link.hpp
。
除了包含 auto_link.hpp
,boost/python/detail/config.hpp
文件还包含:
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_python
这就是 MSVC 试图 autolink
到 libboost_python-vc141-mt-1_64.lib
的原因。
很明显,您的 boost
构建已构建 libboost_python3-vc141-mt-1_64.lib
。正如@kpie 所建议的,您的 boost
构建可能已命名 python 库文件,具体取决于它是为 python 3 还是 python 2...
this 问题的答案描述了如何为 python 3
构建 boost
。它可能会回答您有关构建的宏观问题。
要解决此问题,您可以 disable autolinking,或者简单地重命名库文件以删除“3”。
我使用 MS Visual Studio Professional 2017 和 32 位 Python 3.4 构建了 Boost 1.64.0 Python 库。现在,当我针对生成的库编写应用程序时,出现以下 link 错误:
LINK : fatal error LNK1104: cannot open file 'libboost_python-vc141-mt-1_64.lib'
我查看了 stage/lib 目录,确实,库名为 libboost_python3 -vc141-mt-1_64.lib(注意名称中的3)。我假设 3 引用了 Boost Python 库是使用 Python 生成的事实 3. 为什么构建的库与我的项目尝试的库之间存在命名不一致导入?仅仅是我的项目配置中缺少宏定义吗?
在 MSVC 构建中,boost
headers 使用 MSVC #pragma comments 到 autolink
到 boost
库,请参阅 boost/config/auto_link.hpp
。
除了包含 auto_link.hpp
,boost/python/detail/config.hpp
文件还包含:
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_python
这就是 MSVC 试图 autolink
到 libboost_python-vc141-mt-1_64.lib
的原因。
很明显,您的 boost
构建已构建 libboost_python3-vc141-mt-1_64.lib
。正如@kpie 所建议的,您的 boost
构建可能已命名 python 库文件,具体取决于它是为 python 3 还是 python 2...
this 问题的答案描述了如何为 python 3
构建 boost
。它可能会回答您有关构建的宏观问题。
要解决此问题,您可以 disable autolinking,或者简单地重命名库文件以删除“3”。