c++ - 嵌入 Python : undefined reference to `_imp__Py_Initialize'

标签 c++ python-3.x python-embedding

我正在尝试将 python 3.7.0 嵌入到 C++ 应用程序中并使用 MinGW 进行编译。

#include "Dependencies/include/Python.h"


int main()
{

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

我用这个编译:

g++ ./TestEmbedding.cpp

我收到这个错误:

undefined reference to `_imp__Py_Initialize'

最佳答案

编辑: 找到并回答:

需要包含 python 库文件的路径。我个人现在正在使用 Visual Studio 并将其包含在设置中,但我认为 MinGW 可以通过一些命令行调整来完成。

在库路径中包含与此类似的内容。 C:本地\程序\Python\Python37\Lib

关于c++ - 嵌入 Python : undefined reference to `_imp__Py_Initialize' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52264686/

相关文章:

c++ - clang-tidy:当容器包含特定类时发出警告

C++ vector 、排序和自定义类运算符

c++ - QT宏Q_SLOTS后类访问限制

python - 如何在 matplotlib 中禁用 float

python - 单线程中的 os.mkdir 竞争条件?如何确保在继续之前创建目录

python-3.x - 属性错误: module 'tensorflow_core.keras.layers' has no attribute 'Conv1d'

python - 从 Visual C++ 代码运行 Python(嵌入式 Python)

python - 使用动态版本的 Python 执行嵌入的 Python 代码时出现致命的 Python 错误

python - 限制嵌入式 python 实例的功能

c++ - 一个接受输入小写字母的短程序,它给出大写字母并在按下回车键时退出