|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-18 07:38:00
----- Original Message -----
From: <hugogeek_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, January 18, 2002 5:50 AM
Subject: [boost] first experiences with boost.python
> I have the following in my wrapper "code":
>
> python::class_builder<Terrain> Terrain_class(this_module, "Terrain");
>
> Creating the constructor like so doesn't work:
>
> Terrain_class.def(python::constructor<char*, int, bool, float, float, int,
int>());
>
> Is it the char* that is bothering?
You didn't show us any error messages, but it seems likely that the char* is
giving you trouble. Try char const*; Python strings are immutable so I can't
let you write into one.
> (The docs made me think it does
> support char*.)
>
> Furthermore, as soon as I add any methods:
>
> Terrain_class.def(&Terrain::Render, "Render");
>
> it compiles fine, but when I try to import it in python:
>
> Traceback (most recent call last):
> File "./basic.py", line 5, in ?
> import demeterwrap ImportError: ./demeterwrap.so: undefined symbol:
__tfQ27Demeter7Terrain
>
> I am linking to libDemeter.a just fine, I believe, I have other classes
> also wrapped and they do not cause this problem. (As soon as I remove
> all Terrain_class.def statements, it works fine.)
>
> nm libDemeter.a gives me:
>
> 00002d98 T _._Q27Demeter7Terrain
>
> Can anyone shed light on this problem? Where should I be looking?
Keeping in mind that this is not a Boost.Python-specific problem and you
might be better off asking someone who's a guru w.r.t. your particular
platform and compiler...my guess is that you've left out the definition of
some virtual member function which causes the class' vtbl to come into
existence.
> Can one add members to the python class? (Is my terminology right? I've
> only added methods so far, I also want access to e.g. "float a;". This
> possible?)
RTFM: http://www.boost.org/libs/python/doc/special.html#getter_setter
> Last thing:
>
> WARNING: Python C API version mismatch for module demeterwrap:
> This Python has API version 1010, module demeterwrap has version 1007.
>
> This is because I am using python2.1 while boost.python only supports
> python2.0? (and 1.5.)
Boost.Python supports all Pythons from 1.5 -> 2.2. It's because you compiled
against a set of Python headers for a version later than the version of the
executable you're running.
> I can install python2.0 and work with that if
> necessary. I'm just curious whether it will support 2.1 soon, or maybe
> already... version of the Debian libboost-python-dev package I have:
> Version: 1.21.1-1
Oh, I don't know about that; I didn't release that package. I can only tell
you about the current boost release available at www.boost.org. That will
work with all available Pythons since 1.5.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk