When I attempt to compile a boost.python 'Hello World' program in Visual Studio 2017 on Win10, I run into the following link error:
LNK1104 cannot open file 'boost_python-vc141-mt-1_64.lib'
However, I want to be linking with the python3 version. I built my boost.python libraries with this command
b2 --with-python variant=release link=shared address-model=64
with using python : 3.6 ;
in my project-config.jam file, which produces
boost_python3-vc141-mt-1_64.dll
and boost_python3-vc141-mt-1_64.lib
I have no idea why my project is attempting to link with the python2 version. I never specified anywhere which boost.python library to link with, and I do not know where to change it.
If it matters, here is the c++ program I am attempting to compile (into an x64 .dll)
#include <boost/python.hpp>
char const* greet() {
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext) {
using namespace boost::python;
def("greet", greet);
}
In my experience, on Windows/VC++ Boost.Python's automatic linking always searches for boost_python-vc<blah-blah-blah>.lib
regardless of Python version. And when building against Python 3, b2 actually produces 2 sets of lib files: boost_python-vc...
and boost_python3-vc...
. They are identical, only names differ. So if you don't have boost_python-vc141-mt-1_64.lib
file, rename your boost_python3-vc141-mt-1_64
lib and dll files by removing 3
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.