opencv - 错误 LNK2019 : unsolvable external symbol (OpenCV + VS2012)

标签 opencv visual-studio-2012

我搜索了很多,但没有一个答案有帮助。

我在下面添加了这些东西:

include directory: D:\Program Files (x86)\opencv\build\include
library directory: D:\Program Files (x86)\opencv\build\x86\vc11\lib
additional library directory: D:\Program Files (x86)\opencv\build\x86\vc11\lib
additional dependency: %(AdditionalDependencies);opencv_core248d.lib;opencv_imgproc248d.lib;opencv_ml248d.lib;opencv_video248d.lib;opencv_features2d248d.lib;opencv_calib3d248d.lib;opencv_objdetect248d.lib;opencv_contrib248d.lib;opencv_legacy248d.lib;opencv_flann248d.lib;

我使用的是 64 位机器,但是添加 x64 目录会造成很多麻烦,所以我添加了 x86 目录。

我使用了下面的测试代码:
#include "opencv2/opencv.hpp"

using namespace cv;  
int main()  
{  
    Mat img = imread("../opencv.jpg");  

    if (img.empty())  
    {  
        fprintf(stderr, "Error: load image failed.");  
        return -1;  
    }  
    namedWindow("image", CV_WINDOW_AUTOSIZE);  
    imshow("image", img);  
    waitKey();  

    return 0;  
}  

问题是:(忽略中文部分)
1>test.obj : error LNK2019: unsolvable external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z),该符号在函数 _main 中被引用
1>test.obj : error LNK2019: unsolvable 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@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z),该符号在函数 _main 中被引用

先感谢您!!

最佳答案

请引用 this question 的回答.这可能是由于混合了 64/32 位库和应用程序造成的。

This instruction详细展示了如何使用 VS 构建 opencv 应用程序。希望它会有所帮助。

关于opencv - 错误 LNK2019 : unsolvable external symbol (OpenCV + VS2012),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22395662/

相关文章:

c++ - 在 OpenCV 中计算 ROI 内的对象区域

.net - Visual Studio 2012随机报告:“找不到引用的组件X”

c++ - 为什么我的 visual studio 构建不正确?

visual-studio-2012 - 将静态库添加到同一解决方案中的项目 (Visual Studio 2012)

c++ - 是否/arch :AVX enable AVX2?

python - 使用openCV在python中进行Canny检测

c++ - 获取顶部和底部白色像素的坐标以绘制一条线

Linux 中的 C++ OpenCV2 cv::Mat::copyTo 错误

python - 使用 cv2 在 python 中创建多 channel 零垫

visual-studio - MSBuild 不包含 "VCTargetsPath"属性的值