I have problems linking against boost python.
I am using Visual Studio 2017 and compiled the boost 1_64 package with the following command line:
b2 -a toolset=msvc-14.1 --build_type=complete stage variant=debugthreading=multi link=shared runtime-link=shared define=_ITERATOR_DEBUG_LEVEL=0 address-model=64
with this user-config.jam:
using python
: 3.6 # Version
: C:\Python36\python.exe # Python Path
: C:\Python36\include # include path
: C:\Python36\libs # lib path(s)
: <define>BOOST_ALL_NO_LIB=1
;
But while building my c++ project with runtime libary: Multi-threaded DLL (/MD) I keep getting this error message:
Error LNK1104 cannot open file 'boost_python-vc141-mt-gd-1_64.lib'
but the boost libs I compiled contain the following boost_python files:
boost_python3-vc141-mt-gd-1_64.dll
boost_python3-vc141-mt-gd-1_64.lib
Does someone have experience with boost for python 3? After hours of trying, I can't find a good solution.
Btw.: renaming the files to boost_python- (removing the 3) works fine.
But I don't think that this is the correct way
VC Project settings:
Add. include directories:
C:Python36include;D:wsoost_1_64_0oost_1_64_0;
Add. libary directories:
D:wsoost_1_64_0oost_1_64_0stagelib;C:Python36libs;
Closed: The autolink feature of boost did not work correctly with python 3. The boost_module_name macro was set to boost_python (missing the 3) and the generated libs contained the 3.
--> Turned auto link off and added the required libs manually.
Solution
a) Go to boost/python/detail/config.hpp and change BOOST_LIB_NAMe to boost_python3 instead of boost_python.
or
Solution
b) Turn auto Linkage of by defining BOOST_ALL_NO_LIB and then explicitly set boost_python3...lib as linker dependency.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…