Python: undefined reference to `_imp __Py_InitModule4'

前端 未结 6 991
天涯浪人
天涯浪人 2020-12-05 11:59

I\'m trying to do a debug build of the Rabbyt library using mingw\'s gcc to run with my MSVC built python26_d.. I got a lot of undefined references which caused me to create

6条回答
  •  忘掉有多难
    2020-12-05 12:11

    I just solved this problem by adding the compiler flag -DPy_TRACE_DEFS. In my case I was trying to build debug versions of SIP/PyQt.

    The error can occur when the debug version of Python is compiled with the Py_TRACE_DEFS option switched on. This causes the resulting python2x_d library to contain the function Py_InitModule4TraceRefs instead of Py_InitModule4 that the compiler is looking for (amongst other changes). Switching the option on for the project you are building ensures the code produced is compatible, and that the correct version of Py_InitModule4 is found.

    More information on Py_TRACE_DEFS can be found in Misc/SpecialBuilds.txt in the Python source folder or here.

提交回复
热议问题