[C++-sig] [boost.python] Can't import a wrapped template class
Paul O. Seidon
p.oseidon at datec.at
Fri Oct 26 22:15:42 CEST 2012
Stefan Seefeld wrote:
> On 10/26/2012 02:24 PM, Paul O. Seidon wrote:
>> Paul O. Seidon wrote:
>>
>> That doesn't do it either. I can't help but post the compete code here to
>> be sure I'm not misunderstood. The lib consists of varbls.cpp and
>> varbls.h and the wrapper main.cpp.
>
>> varbls.cpp
>> ==========
>>
>> #include "varbls.h"
>>
>>
>> template <typename TYPE>
>> _Variable<TYPE>::_Variable()
>> : _value( 0)
>> {
>> //ctor
>> }
>
> [...]
>
> What symbols does your compiled varbls.o file export ? I bet none. And
> it can't. That's the problem I'm trying to explain.
>
> Stefan
>
As Alex said, this seems to be a C++ issue. Hope you'll help me
nevertheless. There can't be that much that's missing.
How do I do that export?
This whole mess is caused by the use of a template class. You see, there's a
class VariableFloat. It is not a template class and is not derived from a
template class. And it works, I can use it from w/i my Python modules. Well,
it's deactivated for now to prevent "side effects".
Yes, I have to provide a TYPE to the tempate to enable the compiler to
generate code. Isn't
typedef _Variable<double> VariableDouble;
BOOST_PYTHON_MODULE(_varbls)
{
class_<VariableDouble>("VariableDouble")
.def( init<>())
.def( init<const double&>())
;
}
doing that?
Paul
More information about the Cplusplus-sig
mailing list