Skip to main content
gamedev.net
🔒 Locked

Problems with Boost.Python

Started by Derakon 2 replies 3.7k views
Original Post
Derakon
Derakon
I'm having some problems getting Boost.Python to work. I installed it a while back, and am now working my way through the online tutorial. Or I would be, except that I get stuck on the "We can now build this as a shared library" bit. Here's the file:

#include <boost-1_32/boost/python.hpp>

char const* greet()
{
    return "Hello, world!";
}

using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    def("greet", greet);
}
And here's the compile errors I get:

% make
g++ -g -Wall -pedantic -I/usr/local/include/boost-1_32   -c -o test.o test.cpp
In file included from /usr/local/include/boost-1_32/boost/python/detail/prefix.hpp:13,
                 from /usr/local/include/boost-1_32/boost/python/args.hpp:8,
                 from /usr/local/include/boost-1_32/boost/python.hpp:11,
                 from test.cpp:1:
/usr/local/include/boost-1_32/boost/python/detail/wrap_python.hpp:30:23: pyconfig.h: No such file or directory
/usr/local/include/boost-1_32/boost/python/detail/wrap_python.hpp:54:24: patchlevel.h: No such file or directory
/usr/local/include/boost-1_32/boost/python/detail/wrap_python.hpp:57:2: #error Python 2.2 or higher is required for this version of Boost.Python.
/usr/local/include/boost-1_32/boost/python/detail/wrap_python.hpp:121:21: Python.h: No such file or directory
In file included from /usr/local/include/boost-1_32/boost/python/cast.hpp:13,
                 from /usr/local/include/boost-1_32/boost/python/handle.hpp:10,
                 from /usr/local/include/boost-1_32/boost/python/args_fwd.hpp:10,
                 from /usr/local/include/boost-1_32/boost/python/args.hpp:10,
                 from /usr/local/include/boost-1_32/boost/python.hpp:11,
                 from test.cpp:1:
/usr/local/include/boost-1_32/boost/python/base_type_traits.hpp:24: error: `
   PyObject' was not declared in this scope
/usr/local/include/boost-1_32/boost/python/base_type_traits.hpp:25: error: template
   argument 1 is invalid
/usr/local/include/boost-1_32/boost/python/base_type_traits.hpp:26: confused by earlier errors, bailing out
make: *** [test.o] Error 1
As a best guess, I'd say that my Boost install is screwed up somehow. I'd appreciate any insight people can give, including alternate scripting languages that could be more easily integrated into my C++ game engine. I'm working on MacOS 10.3.8, and my version of Python is 2.4.
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
Kylotan
Kylotan
I would guess that you need to point your compiler at your Python/include directory.
stodge
stodge
Do you have the Python development "package" installed? In other words, do you have the include files and libraries for Python installed? Is pyconfig.h on your disk?
---------------------http://www.stodge.net
Derakon
Derakon
Yes; it's at /usr/local/include/python2.4/pyconfig.h

At the moment, I'm reinstalling Boost, since it looks like I had a poorly-installed copy before. I base this assumption on the fact that luabind requires Boost to install and was complaining about not being able to find files it needed (and some of those files weren't on my hard drive). I'll see how it goes once I've finished the reinstall.
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.