[C++-sig] [Py++] Undefined symbols for static const int member of class

Brian O'Kennedy brokenn at gmail.com
Fri May 21 15:38:53 CEST 2010

Hi Roman,

Thanks for the reply - I've had a look at those unit tests, but were
unable to reproduce the same results in my code. I get an error at
     "AttributeError: 'Boost.Python.StaticProperty' object attribute
'__doc__' is read-only"

How do I go about running the Py++ unit tests?

As a matter of interest, I'm using Boost 1.42.0, Python 2.6.5, CVS
Head of GCCXML, CVS Head of pygccxml, CVS head of pyplusplus.

In any case, I don't actually have write access to the library I want
to wrap, so I needed another solution.

I'm currently simply excluding those static const int members with

In that case, the particular class I'm wrapping works fine!


On 21 May 2010 12:49, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
> On Fri, May 21, 2010 at 1:05 PM, Brian O'Kennedy <brokenn at gmail.com> wrote:
> > Hi,
> > I'm wrapping a very simple class using PyPlusPlus.
> > ---- snip ----
> >  class testclass
> >  {
> >   public:
> >    static const int a = 99;
> >  };
> > ---- /snip ----
> > And Py++ exposes the static member with a def_readonly("a", testclass::a )
> > call. When I import this module into python I get an undefined symbol for
> > testclass::a.
> >   ImportError: ./testwrapper.so: undefined symbol: _ZN9testclass1aE
> > I understand that the static member has no storage and thus boost python
> > cannot find the address of it. However, I was hoping there is a way to solve
> > this kind of (common?) problem using Py++ to perhaps generate a getter
> > function or something similar. How would one do this?
> Try to move "a" initialization to a .cpp file.
> I also suggest you to take a look on Py++ unittests, especially on
> "statics_tester.py" and "statics_to_be_exported.[c|h]pp" files. They
> deal with exactly your use case
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig

More information about the Cplusplus-sig mailing list