Reputation: 53
I tried to import the SWING generated module, but I got an ImportError:
>>> import ava
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ava.py", line 28, in <module>
_ava = swig_import_helper()
File "ava.py", line 24, in swig_import_helper
_mod = imp.load_module('_ava', fp, pathname, description)
ImportError: ./_ava.so: undefined symbol: _Z7turn_aiPPiiii
>>>
I followed SWIG's tutorial (http://www.swig.org/tutorial.html) and I compiled my main.cpp like this:
swig -python -c++ ava.i
c++ -fPIC -c ava_wrap.cxx -I/usr/include/python2.7/
c++ -shared ava_wrap.o -o _ava.so
and I tried to extern my functions to c:
extern "C" {
bool isEnd(int** t, int x, int y, int K, int J);
void tout(int** t, int K);
koord turn(int** t, int player, int K, int J);
koord turn_ai(int** t, int player, int K, int J);
bool isPat(int** t, int K);
ai_res turn_ai_3x3_v2(int** t, int turn);
ai_res turn_ai_pre(int** t, int turn, int K, int J, int dep);
ai_res turn_ai_(int** t, int turn, int K, int J, int ab, int dep);
bool isSeparated(int** t, int K, int i, int j);
std::vector<koord> stepsFun(int** t, int K);
bool isEmpty(int** t, int K);
int value(int** t, int K);
int fofug();
}
Upvotes: 0
Views: 95
Reputation: 59
The problem is with the c++
commands. Your _ava.so
contains the SWIG wrappers, but is missing the implementations for turn_ai
etc.
Look carefully at the SWIG Tutorial, there are example.c
and example.o
which contain implementations of fact
, my_mod
, etc.
Upvotes: 1