Skip to content Skip to sidebar Skip to footer

Configuring Visual Studio To Work With Boost.python And Python 3

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

Solution 1:

With the community help I have found answers to couple of the questions.

  1. Is it possible to influence the logic used by VS to look for Boost.Python library?

Name of library depends on value defined as macro BOOST_LIB_NAME in file boost/python/detail/config.hpp. I have tried to change line (108 in boost 1.64.0)

#define BOOST_LIB_NAME boost_python

to

#define BOOST_LIB_NAME boost_python3

And desirable library file changed from boost_python-vc120-mt-1_64.lib to boost_python3-vc120-mt-1_64.lib.

It should be noted, that instead of changing values in config.hpp file auto_link.hpp can be created and used with redefinition of BOOST_LIB_NAME.

  1. 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 or boost_python3-vc120-mt-1_64.dll instead of boost_python-vc120-mt-1_64.lib?

That is also regulated by defines.

In particular, adding to the beginning of my code (before #include <boost/python.hpp>) the line

#define BOOST_PYTHON_STATIC_LIB

forces MSVS to search file libboost_python3-vc120-mt-1_64.lib (or libboost_python-vc120-mt-1_64.lib), i.e. static lib. And vice versa line

#define BOOST_PYTHON_DYNAMIC_LIB

or

#define BOOST_ALL_DYN_LINK

can be used to import code from a dll.

Post a Comment for "Configuring Visual Studio To Work With Boost.python And Python 3"