C ++ Templates and SWIG do not play well for me.
When I try to import my module, I get an error
ImportError: ./_simple.so: undefined symbol: _Z9double_itIiET_S0_
I am using SWIG 1.3.
Here is a simple example showing the problem:
//file: simple.h template <typename T> T double_it (T a); //file: simple.cc template <typename T> T double_it (T a) { return (2 * a); } //file: simple.i %module "simple" %{
Then create using:
python setup.py build
If I include the contents of simple.cc in simple.i and delete the link to simple.cc from setup.py, then everything works fine, but this is not a solution when the situation becomes more complicated.
Iโll give a counter example of what seems to be, but doesnโt use templates and works fine.
//file: simple.h int double_it (int a); //file: simple.cc int double_it (int a) { return (2 * a); } //file: simple.i //Same as before but with %template statements removed. %module "simple" %{
source share