Embedding Python: undefined reference to `_imp__Py_Initialize'

久未见 提交于 2021-01-28 10:58:38

问题


I am trying to embed python 3.7.0 in a C++ application and use MinGW to compile.

#include "Dependencies/include/Python.h"


int main()
{

    PyObject* myPointer;
    Py_Initialize();
    return 0;
}

I compile with this:

g++ ./TestEmbedding.cpp

I get this error:

undefined reference to `_imp__Py_Initialize'


回答1:


You need to build with Python headers:

g++ TestEmbedding.cpp `python3-config --includes` -o TestEmbedding



回答2:


EDIT: Found and Answer:

The path to the python libs file needs to be included. I personally am now using Visual Studio and just included it in the settings but I think MinGW can do it with some command line adjustments.

include something similar to this in library paths. C:Local\Programs\Python\Python37\Lib



来源:https://stackoverflow.com/questions/52264686/embedding-python-undefined-reference-to-imp-py-initialize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!