我搜索了很多,但没有一个答案有帮助。
我在下面添加了这些东西:
include directory: D:Program Files (x86)opencvbuildinclude
library directory: D:Program Files (x86)opencvbuildx86vc11lib
additional library directory: D:Program Files (x86)opencvbuildx86vc11lib
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 中被引用
提前感谢!!
请参考这个问题的答案。这可能是由于64/32位库和应用程序的混合造成的。
该指令详细展示了如何使用VS构建opencv应用程序。希望能有所帮助。