Python extensions for Win64 via GCC

前端 未结 3 475
小鲜肉
小鲜肉 2021-01-05 01:42

Has anyone had any luck with compiling 64-bit Python extension modules for Windows using mingw64?

I have successfully compiled the extension in question with VS2008

3条回答
  •  伪装坚强ぢ
    2021-01-05 02:28

    There is a mechanism in Python to prevent linking a module against the wrong version of the library. The Py_InitModule4 function is renamed to Py_InitModule4_64 (via a macro) when the library / module is compiled for a 64-bit architecture (see 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
    

    So, if you're getting this error, this means either your Python library, or your Python module is compiled for a 32-bit architecture while the other one is compiled for a 64-bit architecture.

提交回复
热议问题