Boost logo

Boost :

From: edcjones_at_[hidden]
Date: 2001-06-08 09:52:53


Suppose I have some compiled code as a ".a", ".so", or ".o" file. Also
suppose that I have the header files but not the source code. How do I
use Boost.Python to wrap the stuff?

Here is an attempt at an example based on "getting_started1". What did
I do wrong?
-----------------------
gs1.hpp:

#include <string>

std::string greet();
int square(int number);

-----------------------
gs1src.cpp:

#include "gs1.hpp"

std::string greet() { return "hello, world"; }
int square(int number) { return number * number; }

-----------------------
gs1.cpp:

#include "gs1.hpp"
#include <boost/python/class_builder.hpp>

namespace python = boost::python;

BOOST_PYTHON_MODULE_INIT(getting_started1)
{
  try
  {
    python::module_builder this_module("getting_started1");
    this_module.def(greet, "greet");
    this_module.def(square, "square");
  }
  catch(...)
  {
    python::handle_exception();
  }
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk