VS LINK无法打开文件'boost_python ...'而不是libboost_python3-vc140-mt-gd-1_65 [英] VS LINK cannot open file 'boost_python...' instead of libboost_python3-vc140-mt-gd-1_65
问题描述
今天早上,我安装了Python 3.6,安装了b2配置来编译boost lib,并且lib路径中都包含libboost_python3...
两种风格.然后简单:
This morning I installed Python 3.6, got my b2 config to compile the boost lib and do have both flavors of libboost_python3...
in the lib path. Then with a simple:
#include "stdafx.h"
#include <boost/python.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
我收到链接器错误:
LINK : fatal error LNK1104: cannot open file 'boost_python-vc140-mt-gd-1_63.lib'
我已经搜索了像USING_BOOST_PYTHON3
这样的标志,但是我读到的每件事都说它应该是自动的.根据我的构建,Boost应该包含适当的库.
I've searched for the likes of a flag like USING_BOOST_PYTHON3
but every thing I read says that it should be automatic. That Boost should include the proper lib according to what I've built.
此家伙遇到了同样的问题,但是没有得到答案.这与我在右边的类似问题"中的链接所能获得的接近.但是我看不到VS是其中的一部分,因为boost会选择libs.
This guy Had the same problem but never got an answer. That was as close as I could get to the links in 'Similar Questions' on the right. But I can't see how VS is part of this as boost will pick the libs.
更新:我刚刚找到:
#if PY_MAJOR_VERSION == 2
# define BOOST_LIB_NAME boost_python
#elif PY_MAJOR_VERSION == 3
# define BOOST_LIB_NAME boost_python3
#endif
所以现在看来,为什么我的主要版本是2而不是3?即使我:
So now it looks like why is my major version 2 instead of 3? And even if I:
#define PY_MAJOR_VERSION 3
在我的stdafx.h
顶部,它仍然与python 2 lib链接. !?
Right at the top of my stdafx.h
it still links with the python 2 lib. !?
又一次更新:
这么早,我还没有安装python 2.7,我已经将其他库"设置为C:\cpp\Python27\libs
,我只是将其设置为C:\cpp\Python36_3\libs
,现在我得到了:
Yet Another Update:
So early on, and I don't have python 2.7 'installed', I had set the Additional Libraries to C:\cpp\Python27\libs
I just set it to C:\cpp\Python36_3\libs
and now I get:
LINK : fatal error LNK1104: cannot open file 'python27.lib'
感觉很有意义,因为boost正在尝试链接到2.x而不是3.x
Makes sense as boost is trying to link to 2.x instead of 3.x
推荐答案
#define BOOST_PYTHON_STATIC_LIB
链接:libboost_python3-vc140-mt-s-1_65_1.lib
link: libboost_python3-vc140-mt-s-1_65_1.lib
这篇关于VS LINK无法打开文件'boost_python ...'而不是libboost_python3-vc140-mt-gd-1_65的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!