Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-06-08 10:56:39


It's really hard to say without knowing what error messages, etc., you may
have received. What you've written looks reasonable to me, at first glance.
What compiler are you using? What happens when you try to build your module?

-Dave

----- Original Message -----
From: <edcjones_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, June 08, 2001 10:52 AM
Subject: [boost] Newbie Question (Boost.Python): How to wrap libraries
without source code?

> 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();
> }
> }
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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