我想编译非常简单的文件到python在Windows上,我的时间不好。使用swig编译C++到python
的.i文件是testfile.i:
%module testfile
%include "stl.i"
%{
int get_num() {
return 3;
}
%}
int get_num() {
return 3;
}
的痛饮功能: {痛饮路径} \ swig.exe -C++ -python testfile.i
这工作完全,我现在得到了testfile.py文件和testfile_wrap.cxx文件。 现在我明白,我需要将它编译到库(windows上的.pyd)。我试过:
{gcc path} \ gcc.exe -fPIC -shared testfile_wrap.cxx -o testfile_wrap.pyd -L。 -LC:\ Python27 \ libs \ -lpython27 -IC:\ python27 \ include。
这是问题所在,我得到了很多这样的人的错误:
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'
而且它继续和。
我在做什么错?
谢谢您的帮助
更新: 我设法打电话痛饮和使用的Visual Studio 2013编译/链接,但我得到了同样的错误。我遵循教程,它仍然无法正常工作。
这将是因为你的gcc正在编译一个32位共享对象,这在Windows上很常见。有64位gcc版本可用于Windows,如果你有兴趣:http://mingw-w64.org/doku.php –
我实际上尝试过它,同样的问题。而我的视觉工作室也是64位,太奇怪了 – MyNick