我使用MS Visual Studio Professional 2017和32位Python 3.4构建了Boost 1.64.0 Python库。现在,当我针对生成的库编写应用程序时,我收到以下链接错误:
LINK:致命错误LNK1104:无法打开文件'libboost_python-vc141-mt-1_64.lib'
我查看了 stage / lib 目录,实际上,该库名为 libboost_python 3 -vc141-mt-1_64.lib (注意名称中的 3 )。我假设3引用了Boost Python库是使用Python 3生成的。为什么构建的库和我的项目试图导入的库之间存在命名不一致?它只是我项目配置中缺少的宏定义吗?
答案 0 :(得分:1)
在MSVC版本中,boost
标题使用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问题的答案介绍了如何为boost
构建python 3
。它可能会回答您关于构建的宏问题。
要解决此问题,您可以disable autolinking,或者只是重命名库文件以删除" 3"。