2010-09-23 44 views
8

有没有人有使用mingw64编译Windows的64位Python扩展模块的运气?通过GCC的Win64 Python扩展

我已经成功编译了这个平台的VS2008的问题扩展。我还用mingw32编译了它(使用32位python)。我宁愿两个版本都使用GCC。

我已经使用Cygwin安装了mingw64-x86_64-w64 GCC 4.5.1工具集,并确信Python使用它们。但是,链接到python本身失败。

所以我拿起pexports 0.44,用它来转储出python26.def文件并创建libpython26.a

现在,在this question中,我从Python获得的唯一链接错误大约是__imp_py_InitModule4。浏览def文件,我看到一个Py_InitModule4_64符号。

任何想法?

+2

我建议你问问mingw-w64项目寻求帮助。他们通常非常敏感...... – 2010-10-01 08:02:21

回答

3

Python中有一种机制可以防止链接模块与库的错误版本。该Py_InitModule4功能(通过宏)更名为Py_InitModule4_64当库/模块编译为64位架构(见modsupport.h):

#if SIZEOF_SIZE_T != SIZEOF_INT 
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4 
    modules cannot get loaded into a 2.5 interpreter */ 
#define Py_InitModule4 Py_InitModule4_64 
#endif 

所以,如果你得到这个错误,这意味着你的Python库,或者你的Python模块被编译为32位体系结构,而另一个编译为64位体系结构。

4

我找到你需要定义MS_WIN64以及WIN32,也Distutils的包不理解mingw64,见this后,和this一个

修补的distutils支持mingw64是相当微不足道。