您的位置:首页 > 编程语言 > Python开发

编译OpenCV缺少python27_d.lib的解决方法

2018-02-12 14:58 344 查看
错误 24error LNK1104: 无法打开文件“python27_d.lib”  C:\OpenCV\VS2013_64\modules\python\LINK opencv_python
一个妥协的方法是注释掉会使用python27_d.lib部分的代码,替换为使用python27.lib
具体做法如下:在OpenCV项目的bindings中的opencv_python项目中,点击“外部依赖项”,在其中找到pyconfig.h和object.h文件:在pyconfig.h中将[cpp] view plain copy#ifdef _DEBUG  
#   define Py_DEBUG  
#endif  
修改为:[cpp] view plain copy#ifdef _DEBUG  
//# define Py_DEBUG  
#endif  
[cpp] view plain copy/* 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 */  
修改为[cpp] view plain copy/* 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.lib")  
#           else  
#               pragma comment(lib,"python27.lib")  
#           endif /* _DEBUG */  
#       endif /* _MSC_VER */  
#   endif /* Py_BUILD_CORE */  
#endif /* MS_COREDLL */  
在object.h中将
[cpp] view plain copy/* Py_DEBUG implies Py_TRACE_REFS. */  
#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)  
#define Py_TRACE_REFS  
#endif  
修改为[cpp] view plain copy/* Py_DEBUG implies Py_TRACE_REFS. */  
#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)  
//#define Py_TRACE_REFS  
#endif  

保存之后,再次编译就成功啦!
转载来源:http://blog.csdn.net/pplxlee/article/details/78067927
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: