[C++-sig] undefined symbols with def_readonly

Stefan Seefeld seefeld at sympatico.ca
Thu Apr 10 15:35:12 CEST 2008

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.)



       ...ich hab' noch einen Koffer in Berlin...

More information about the Cplusplus-sig mailing list