OpenCV:windows下链接或运行时出现的问题

1. 链接时出现”无法解析的外部符号”

1>Histogram1D.obj : error LNK2019: 无法解析的外部符号 “public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)” (??0_InputArray@cv@@QAE@ABVMat@1@@Z),该符号在函数 “public: class cv::Mat __thiscall Histogram1D::getHistogram(class cv::Mat const &)” (?getHistogram@Histogram1D@@QAE?AVMat@cv@@ABV23@@Z) 中被引用
1>Histogram1D.obj : error LNK2019: 无法解析的外部符号 “public: __thiscall cv::_OutputArray::_OutputArray(class cv::Mat &)” (??0_OutputArray@cv@@QAE@AAVMat@1@@Z),该符号在函数 “public: class cv::Mat __thiscall Histogram1D::getHistogram(class cv::Mat const &)” (?getHistogram@Histogram1D@@QAE?AVMat@cv@@ABV23@@Z) 中被引用
1>Histogram1D.obj : error LNK2019: 无法解析的外部符号 “public: void __thiscall cv::Mat::copySize(class cv::Mat const &)” (?copySize@Mat@cv@@QAEXABV12@@Z),该符号在函数 “public: __thiscall cv::Mat::Mat(class cv::Mat const &)” (??0Mat@cv@@QAE@ABV01@@Z) 中被引用
1>Histogram1D.obj : error LNK2019: 无法解析的外部符号 “int __cdecl cv::_interlockedExchangeAdd(int *,int)” (?_interlockedExchangeAdd@cv@@YAHPAHH@Z),该符号在函数 “public: __thiscall cv::Mat::Mat(class cv::Mat const &)” (??0Mat@cv@@QAE@ABV01@@Z) 中被引用
1>main.obj : error LNK2001: 无法解析的外部符号 “int __cdecl cv::_interlockedExchangeAdd(int *,int)” (?_interlockedExchangeAdd@cv@@YAHPAHH@Z)
解决方法
把包含opencv_world340.dll的目录添加到环境变量Path中,如我的目录:C:\opencv\opencv\build\x64\vc15\bin

2.运行时出现”无法启动此程序,因为此计算机中丢失opencv_world340.dll”
解决方法
将前边bin目录(C:\opencv\opencv\build\x64\vc15\bin)中的3个dll文件复制到C:\Windows\System32或者C:\Windows\SysWOW64中。(测试时发现必须复制到C:\Windows\System32中才有效)

猜你喜欢

转载自blog.csdn.net/u013187057/article/details/80111362