使用LNK 2019无法解析的外部符号链接OpenCV失败

时间:2019-03-25 15:01:35

标签: c++ visual-studio opencv opencv3.0

我知道,仍然有一些关于该主题的请求,但是我想我做了所有事情,都写在那里。我刚刚下载了OpenCV,但无法运行。

我做了以下事情:
添加环境变量OPENCV_DIR = .. \ opencv \ build \ x64 \ vc14
添加环境变量Path =%OPENCV_DIR%/ bin

属性-> C / C ++->常规->其他,包括设置为../ opencv / build / include

的目录

属性->链接器->常规->添加了其他库目录。./opencv / build / x64 / vc14 / lib

属性->链接器->常规->添加了其他库目录../ opencv / build / lib / Debug

属性->链接器->输入->添加的其他依赖项:
opencv_calib3d343d.lib
opencv_core343d.lib
opencv_features2d343d.lib
opencv_flann343d.lib
opencv_highgui343d.lib
opencv_imgcodecs343d.lib
opencv_imgproc343d.lib
opencv_ml343d.lib
opencv_objdetect343d.lib
opencv_photo343d.lib
opencv_shape343d.lib
opencv_stitching343d.lib
opencv_superres343d.lib
opencv_ts343d.lib
opencv_video343d.lib
opencv_videoio343d.lib
opencv_videostab343d.lib
opencv_world343d.lib

将CPU调试设置为x64

我的代码很简单:

#include <iostream>
#include "opencv2/opencv.hpp"

int main() {
    cv::Mat SrcImg = cv::imread("C:\\HomeC\\Screenshots\\SC_01.bmp", -1);

    std::cout << "Application finished. Press ENTER to exit..." <<     std::endl;
    std::cin.ignore();
}

我得到的错误是:
LNK2019 unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPEAHH@Z) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release@Mat@cv@@QEAAXXZ)


LNK2019 unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function main

因此,您可以看到,我阅读了文档,仍然在Google上搜索有关该OpenCV错误的所有内容。

有人有另一个想法,如何使其运行?

关于, 扬

1 个答案:

答案 0 :(得分:0)

好的,现在可以了。我也必须在path文件夹中指定包含dll的文件夹。我还重新安排了该项目,因为我在旧项目中也通过NuGet引用了OpenCV。