Missing Python.h while trying to compile a C extension module

前端 未结 3 1404
灰色年华
灰色年华 2020-12-10 05:17

I\'m following this tutorial on how to extend Python with C\\C++ code.

The section named \"Building the extension module with GCC for Microsoft Windows\" fails for m

3条回答
  •  死守一世寂寞
    2020-12-10 05:53

    1. Do you have the python dev files so that you can find Python.h?
    2. Do you have the location of Python.h specified to your compiler? with gcc this is usually done through a -I path to include.

    Figuring out which of those is failing will solve your problem.

    from the article you linked:

    gcc -c hellomodule.c -I/PythonXY/include

    gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll

    They assumed you installed python in the default location c:\pythonXY(Where X is the major version number and Y is the minor version number).(in your case Python26) If you put python somewhere else replace /PythonXY with where ever you installed it.

提交回复
热议问题