[C++-sig] undefined symbols with def_readonly

Neal Becker ndbecker2 at gmail.com
Fri Apr 11 14:22:14 CEST 2008


Stefan Seefeld 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.)
> 
> Regards,
> Stefan
> 

The above solution works fine, thanks.




More information about the Cplusplus-sig mailing list