Visual Studio 2019 重新生成 OpenCV 解决方案报 LNK2019 无法解析的外部符号 __imp__Py_NegativeRefcount、__imp_Py_RefTotal
- 错误问题详情
- 解决方法
- 修改 `pyconfig.h`
- 修改 `object.h`
错误问题详情
解决方法
原因: 这是因为使用的 python 是 Release 版,而编译是在 Debug 模式下编译的(Release 模式下没有此问题)
在 python 的安装位置找到 include
文件夹,在文件夹下找到 pyconfig.h
、object.h
文件
因为我用的是 anaconda3 装的,所以
我的 pyconfig.h
位置为 D:\Programs\anaconda3\include\pyconfig.h
我的 object.h
位置为 D:\Programs\anaconda3\include\object.h
修改 pyconfig.h
注释 # define Py_DEBUG
修改前:
#ifdef _DEBUG
# define Py_DEBUG
#endif
修改后:
#ifdef _DEBUG
#endif
如图所示:
修改前:
修改后:
修改 object.h
注释 #define Py_REF_DEBUG
修改前:
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
#define Py_REF_DEBUG
#endif
修改后
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
#endif
如图所示:
修改前:
修改后:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)