我正在尝试使用 "#include <Python.h>"
在 C++ 中运行 Python 模块,但是,在将项目的“附加包含依赖项”设置为“\include”后,调试时出现以下错误,
LINK : fatal error LNK1104: cannot open file 'python27_d.lib'
我读到我应该下载 Python 的开发版本,但我没有找到链接,另外,我不需要将文件“python27_d.lib”复制到“libs”文件夹?
请注意,我使用的是 Python 的 Anaconda 发行版。
提前致谢!
最佳答案
我通常通过在调试版本中使用非调试 Python 库来规避这一点。通常,这会导致如下代码:
#ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
在包含 Python.h 期间隐藏 _DEBUG 定义的位置。
关于c++ - 为什么#include <Python.h> 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16200997/