[C++-sig] undefined symbols with def_readonly

Roman Yakovenko roman.yakovenko at gmail.com
Thu Apr 10 15:43:48 CEST 2008


On Thu, Apr 10, 2008 at 4:35 PM, Stefan Seefeld <seefeld at sympatico.ca> wrote:
> Neal Becker wrote:
>
>  > Surprisingly, this still doesn't work:
>  > ...
>  >     .setattr ("TAIL_BITS", turbo_enc_1_15::TAIL_BITS)
>  >
>  > ImportError: ../mod/turbo_enc_1_15.so: undefined symbol: _ZN14turbo_enc_1_159TAIL_BITSE
>
>  And this:
>
>  int const tail_bits = turbo_enc_1_15::TAIL_BITS;
>
>  ...
>  .setattr("TAIL_BITS", tail_bits)
>
>  ?
>
>  Note that the class_<>::setattr() method still takes a reference of its
>  second argument, which, if the compiler doesn't optimize it away, emits
>  a symbol reference. So, introducing this local 'tail_bits' variable has
>  basically the same effect as defining turbo_enc_1_15::TAIL_BITS. The
>  latter would obviously be the more proper solution to your problem, but
>  if you don't want or can't do that, such a local variable may be a
>  viable workaround. (Not sure how portable it is, though.)

May be you should try some other way:

using boost::python;
scope().attr("TAIL_BITS") = object(TAIL_BITS);

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list