Creating / Enabling Boost.Python in VS2013

Can someone tell me that I am doing something wrong.

I work on Windows 7 using Visual Studio 2013, and I would like to be able to set up a simple Boost.Python project. I do not know if I did something wrong building boost or when including boost in my project.

Mistake

When I try to execute #include any python boost module, for example. #include <boost/python/module.hpp> The following error appears in Visual Studio.

 1>c:\boost_1_55_0\boost\python\detail\wrap_python.hpp(50): fatal error C1083: Cannot open include file: 'pyconfig.h': No such file or directory 

Building

I tried to follow the instructions from this SO thread, in which KTC refers to Python , and this Python howto from Boost , but since both links are outdated, different things are done, and some of the steps seem to have changed in new versions of Boost, I had to improvise some from the instructions.

This is what I did.

  • Unzip the latest version (1.55) of the original Boost file to C:\boost_1_55_0 .
  • Used by cmd.exe to navigate to C:\boost_1_55_0 . (I did not use the Developer Command Prompt for VS2013 , found under \Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts . That shouldn't matter, right? The official guide for 1.55 does not increase the mention of using Command Prompt for VS2013 .
  • Used bootstrap in cmd.
  • Edited project-config.jam (created by bootstrap ) and added path to my installation of Python 3.4 C:\Python34 . My .jam file now looks as shown in Project-Config.jam .
  • Used .\b2 in cmd to start the build process. While I had many warnings during the built-in ( forcing value to bool 'true' or 'false' (performance warning) , etc.), After the built was completed, it seemed that there were no messages about errors.

Including

This is how I created my project in Visual Studio.

  • Created a new project.
  • Added code shown in Test Code .
  • In the VC ++ directories in the project properties:
    • Added C:\boost_1_55_0 to Include Directories .
    • Added C:\boost_1_55_0\stage\lib (the folder where I could find the .lib files) in Library Directories .

Project-Config.jam

 import option ; using msvc ; option.set keep-going : false ; using python : 3.4 : C:\\Python34\\python ; 

Test code

From: boost_1_55_0\libs\python\example\getting_started1.cpp

 #include <boost/python/module.hpp> #include <boost/python/def.hpp> #include <string> namespace { // A couple of simple C++ functions that we want to expose to Python. std::string greet() { return "hello, world"; } int square(int number) { return number * number; } } namespace python = boost::python; BOOST_PYTHON_MODULE(getting_started1) { // Add regular functions to the module. python::def("greet", greet); python::def("square", square); } 
+8
c ++ python boost visual-studio boost-python
source share
1 answer

It seems I just need to add the path to Python34/include/ and Python34/libs/ in my Include and Library dependencies.

+10
source share

All Articles