I'm trying to compile very simple file to python on windows and I'm having a bad time.
The .i file is testfile.i:
%module testfile
%include "stl.i"
%{
int get_num() {
return 3;
}
%}
int get_num() {
return 3;
}
The swig function: {swig path}\swig.exe -c++ -python testfile.i
This works perfectly, I now got the testfile.py file and testfile_wrap.cxx file. Now I understood that I need to compile this to library (.pyd on windows). I tried:
{gcc path}\gcc.exe -fPIC -shared testfile_wrap.cxx -o testfile_wrap.pyd -L. -LC:\Python27\libs\ -lpython27 -IC:\python27\include.
Here is the problem, I get alot of errors like this ones:
C:\Users\itay\AppData\Local\Temp\ccANsNeU.o:testfile_wrap.cxx:(.text+0xc00): undefined reference to `__imp_PyExc_MemoryError'
C:\Users\itay\AppData\Local\Temp\ccANsNeU.o:testfile_wrap.cxx:(.text+0xc13): undefined reference to `__imp_PyExc_IOError'
C:\Users\itay\AppData\Local\Temp\ccANsNeU.o:testfile_wrap.cxx:(.text+0xc26): undefined reference to `__imp_PyExc_RuntimeError'
C:\Users\itay\AppData\Local\Temp\ccANsNeU.o:testfile_wrap.cxx:(.text+0xc39): undefined reference to `__imp_PyExc_IndexError'
And it continues on and on.
What am I doing wrong?
Thank you for your help
Update: I managed to call swig and compile/link using visual studio 2013 but I get the same error. I followed tutorials and it still does not work.
The solution: my python was 64 bit and it didn't work. Changed to python 32 bit and now it is working (python 2.7.10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With