我刚刚用 Panda3D 开始了一个 C++ 项目。 ( Visual Studio 2010)
通过一个简单的 HelloWorld,我添加了路径等。没有编译错误,除了:
刚出现一个错误:
error LNK1104: cannot open file 'python27_d.lib'
而且我不知道如何修复它。
请帮忙!
谢谢!
最佳答案
您可以做一些事情。
1) 只在 Release模式下构建(不是一个好的解决方案,因为你不能用这种方式调试得太好)
2) 添加另一个基于“Release”但带有调试符号且没有_DEBUG
预处理器定义的构建配置(可能会弄乱一些库)
3) 使用 Visual Studio 2010 中构建的调试和发布库查找或构建 Python 2.7 版本
4) 只需更改 pyconfig.h
中的这一部分,它实际链接到 *.lib 文件以仅将 python27.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
# //-----------------------change the next line-------------//
# pragma comment(lib,"python27_d.lib")
# else
# pragma comment(lib,"python27.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
1) 2) 和 4) 是 hacky 解决方案,所以我建议您尝试使用 3)。
关于c++ - 无法打开 lib python。 Panda3D 项目。 VS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19636336/