Having some issues, now I have read the following:
hello world python extension in c++ using boost?
I have tried installing boost onto my desktop, and, done as the posts suggested in terms of linking. I have the following code:
#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;
Now I have tried linking with the following:
g++ testing.cpp -I /usr/include/python2.7/pyconfig.h -L /usr/include/python2.7/Python.h
-lpython2.7
And I have tried the following as well:
g++ testing.cpp -I /home/username/python/include/ -L /usr/include/python2.7/Python.h -lpython2.7
I keep getting the following error:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such
file or directory
# include <pyconfig.h>
I don't know where I am going wrong. I do have boost.python installed, there's just a problem linking?
I just had the same error, the problem is g++ can't find pyconfig.h(shocking, I know). For me this file is located in /usr/include/python2.7/pyconfig.h
so appending -I /usr/include/python2.7/
should fix it, alternatively you can add the directory to your path with:
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/include/python2.7/"
You can also add this to your .bashrc and it will be added whenever you start your shell next(you will have to reopen your terminal to realize the changes).
You can find your own python include path by using find /usr/include -name pyconfig.h
, in my case this returns:
/usr/include/python2.7/pyconfig.h
/usr/include/i386-linux-gnu/python2.7/pyconfig.h