VS2008/VS2013 C++调用Python Build出错cannot open file 'python27_d.lib'

之前步骤链接如下:

C/C++内嵌python环境 Python编译成EXE

若按照之前的步骤build时还是会出错,错误信息如下:

fatal error LNK1104: cannot open file 'python27_d.lib'

 

原因:我们使用的头文件 调用了"pyconfig.h"

#include "pyconfig.h"

 

而在"pyconfig.h"中有用到"python27_d.lib"

/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
# ifdef _DEBUG
# pragma comment(lib,"python27_d.lib")
# else
# pragma comment(lib,"python27.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

 

比较简单的解决办法是:

请将C:/Python27/libs下的python27.lib复制一份改名为python27_d.lib

你可能感兴趣的:(C/C++,Python)