I had Microsoft Visual Studio Community 2013 (Version 12.0.31101.00 Update 4) and Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017) on my PC with Windows 10 Pro.
In order to try examples with Boost.Python I downloaded boost 1.64.0 and build libraries by b2
with options --with-python --toolset=msvc --build-type=complete
. As a result I have the following files:
- boost_python3-vc120-mt-1_64.dll
- boost_python3-vc120-mt-1_64.lib
- boost_python3-vc120-mt-gd-1_64.dll
- boost_python3-vc120-mt-gd-1_64.lib
- libboost_python3-vc120-mt-1_64.lib
- libboost_python3-vc120-mt-gd-1_64.lib
- libboost_python3-vc120-mt-s-1_64.lib
- libboost_python3-vc120-mt-sgd-1_64.lib
- libboost_python3-vc120-s-1_64.lib
- libboost_python3-vc120-sgd-1_64.lib
Then I created project (type: Win32 / DLL) in Visual Studio with the following code taken here:
char const* greet()
{
return "hello, world";
}
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello)
{
using namespace boost::python;
def("greet", greet);
}
In project properties for C/C++ settings I added "Additional Include Directories" to locations of Boost and Python (ends with \Python36\include).
During the first attempt to build the project an error appears:
Error 1 error LNK1104: cannot open file 'python36.lib'
So in project properties for Linker settings "Additional Library Directories" I added corresponding location (ends with \Python\Python36\libs). After that I could move on ... to the next error:
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-gd-1_64.lib'
It is noteworthy that the difference in filenames I had and VS2013 looking for is just digit 3
after word python
.
Similar questions at stackoverflow and in google groups are discussed but without valuable tips. The only useful information is that library file names *boost_python-*
corresponds to Python 2 and *boost_python3-*
to Python 3.
I noticed that changing the build type (Solution Configuration) from Debug to Release leads to change the error message in part of library file name (there is no -gd-
now):
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-1_64.lib'
I suppose, VS2013 knows boost library file name convention, but probably does not know the difference about Python 2 and Python 3.
So, I have 3 questions:
- Is it possible to influence the logic used by VS to look for Boost.Python library? (Of course lib-files renaming is also an option, but I do not like this for some reason)
- Do the linker options allow specifying lib-file directly? (i.e. I can write whole path to the
boost_python3-vc120-mt-1_64.lib
including file name, not just folder name in section "Additional Library Directories") - What option in the project properties should make VS2013 to use different LIB or DLL files, e.g.
libboost_python3-vc120-mt-1_64.lib
orboost_python3-vc120-mt-1_64.dll
instead ofboost_python-vc120-mt-1_64.lib
?