1

I've searched a lot but none of the answers help.

I added these things below:

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;

I'm using 64-bit machine but adding x64 directory cause a lot of trouble, so I add x86 directory instead.

I used the test code below:

#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;  
}  

And the problem is: (ignore the Chinese part)

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 中被引用

Thank you in advance!!

Hermione
  • 51
  • 1
  • 7
  • What kind of target you are making? `win32` or `x64`? The linker error indicates that the corresponding libraries is not added. – feihu Mar 14 '14 at 04:13
  • @feihu win32 (I tried x64 before, also get this error) – Hermione Mar 14 '14 at 04:16
  • what about the application you are building? I mean the BUILD -> Configration Manager -> platform, is it also `win32`? – feihu Mar 14 '14 at 04:18
  • yes, it's also win32.. there is only "win32" in BUILD -> Configration Manager -> platform @feihu – Hermione Mar 14 '14 at 04:38
  • `opencv_highgui[xxx]d.lib` is for `cv::namedWindow` and `cv:waitKey`, it seems that you didn't include this library. You could add it and try again to see if the error messages change? – feihu Mar 14 '14 at 04:42
  • since this is a very easy program, I recommend you take a look this [introduction](http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to) to see if any setting is missing. – feihu Mar 14 '14 at 04:46
  • Thank you! I read that introduction before. Adding highgui helps to compile, but get `Application fails to start(oxc000007b)` @feihu – Hermione Mar 14 '14 at 05:15
  • please refer to this [post](http://msoos.wordpress.com/2010/09/11/0xc000007b-error-solution/) – feihu Mar 14 '14 at 06:07

1 Answers1

0

Please refer to the answer to this question. It's probably caused by the mixing up 64/32 bit libraries and application.

This instruction shows how to build opencv applications using VS in detail. Hope it would help.

Community
  • 1
  • 1
feihu
  • 1,935
  • 16
  • 24
  • Thank you! I restart the computer and it works.. I believe highgui is the key. (really hate window and vs!) – Hermione Mar 14 '14 at 06:07
  • @Hermione, that's strange. Restart computer usually helps without know the reason:-) – feihu Mar 14 '14 at 06:08
  • Iinstructions link is no longer valid. The right link: https://docs.opencv.org/master/dd/d6e/tutorial_windows_visual_studio_opencv.html – Roy Shilkrot Feb 06 '19 at 23:18