问题
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