c++ - 为什么#include <Python.h> 不起作用?

标签 c++ python visual-studio-2010 wrapper

我正在尝试使用 "#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/

相关文章:

c++ - 仅当在 Visual Studio 之外运行 EXE 时才会出现发布错误

没有模板的 C++11 内联 lambda 函数

c++ - 关于 Vulkan 中的函数加载器

python - 小部件未显示在网格布局 (PySide) 上

python - 方法中的单个字符串或字符串列表

c++ - SDL 错误。 OpenGL 激活,使用 SDL_GL_SwapBuffers()

c++ - 我可以像 C# 的 Action 一样使用 C++ 函数指针吗?

c++ - 如何 checkin 与 SQL Server 数据库的 C++ 代码连接?

python - 如果在 Matplotlib 中指定图形大小,图形标题 (suptitle()) 会消失

visual-studio-2010 - VS2010 : "Unable to start debugging"