Can someone tell me if I'm doing anything wrong.
I'm on Windows 7 using Visual Studio 2013 and I would like to be able to be able to setup a simple Boost.Python project. I don't know if I've made something wrong building boost or when including boost in my project.
Error
When I try to #include
any boost python module, e.g. #include <boost/python/module.hpp>
I get the following error 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 instructions from this SO thread in which KTC addresses Python, and this Python howto from Boost, but since both links are bit dated, are doing things differently, and some of the steps seems to have changed in newer versions of Boost, I had to improvise on some of the instructions.
This is what I did.
C:\boost_1_55_0
.cmd.exe
to navigate to C:\boost_1_55_0
. (I did not use Developer Command Prompt for VS2013
found under \Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
. This shouldn't make any difference, should it? Boosts official guide for 1.55 didn't make any specific mentioning of using Command Prompt for VS2013
.bootstrap
in cmd.project-config.jam
(created by bootstrap
) and added path to my Python 3.4 installation C:\Python34
. My .jam
file now looked like as seen in Project-Config.jam..\b2
in cmd to start the build process. While I had a lot of warnings during the built (forcing value to bool 'true' or 'false' (performance warning)
, etc.), it didn't seem to be any error messages after the built was finished.Including
This is how I created my project in Visual Studio.
C:\boost_1_55_0
to Include Directories
.C:\boost_1_55_0\stage\lib
(the folder where I could find .lib
files) to 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);
}
It seems I just needed to add a path to Python34/include/
and Python34/libs/
in my Include and Library dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With