(Boost.Python) How to load header files?

Q

Qun Cao

Hi Everyone,

I just started to use boost.python and having problem trying to get my
first program working.

I have a C++ class foo.cpp, defined in foo.h, I wrote a wrapper class
for it to generate a python module.

#include "Foo.h"

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(mymodule)
{
class_<Foo>("Foo")
.def ("init", &Foo:init)

}

The problem is that when I bjam it, the compiler cannot find the header
file <Foo.h>, although I had the location of Foo.h added into $PATH. I
can make it work by copying Foo.h into the working directory, but Foo.h
is also depended on other libraries, so I need a generic way to
recognize the header files.

Thanks for any hit,
Qun
 
N

Neil Hodgson

Qun said:
I have a C++ class foo.cpp, defined in foo.h, I wrote a wrapper class
for it to generate a python module.

#include "Foo.h"

If you are on Windows it shouldn't matter but try to keep
capitalisation consistent: #include "foo.h".
The problem is that when I bjam it, the compiler cannot find the header
file <Foo.h>, although I had the location of Foo.h added into $PATH.

Headers don't go into $PATH. The bjam way is to use an include
dependency in the Jamfile. One of my Jamfile's looks something like this
with extra stuff removed:

extension SinkWorld
: # sources
SinkWorld.cpp
:
<include>../../base
<include>../../lexers
;

I'm not a Jam or Boost expert and the best place for Boost.Python
questions is
http://mail.python.org/mailman/listinfo/c++-sig

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top