Ask Your Question
0

Accessing OpenCV DLLs from VS2012

asked 2013-07-16 13:55:47 -0600

gt324 gravatar image

I am trying to write an application in C++ using VS2012 and OpenCV. I have tried to follow the instruction in the very early tutorial promisingly entitled How to build applications with OpenCV inside the Microsoft Visual Studio. I thought that it would be easiest to use the DLLs provided, but find most of the instructions refer to the other way (using .lib files)

I have set the include directory to be ....opencv\build\include

I was not quite sure how to refer to the dlls as I am not used to using them, but it looked like I should either set the executable directories, Library Directories or the reference directories to ....\opencv\build\x64\vc11\bin, so I set all three to this

I tried to run the example program provided at the end of the tutorial and got lots of errors.

I removed most of the program so that only one reference to the OpenCV library remained

VideoCapture captRefrnc(sourceReference),
             captUndTst(sourceCompareWith);

And this just produced the error message

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------ 1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::VideoCapture::VideoCapture(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (??0VideoCapture@cv@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main 1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::VideoCapture::~VideoCapture(void)" (??1VideoCapture@cv@@UAE@XZ) referenced in function _main 1>C:\Users\Graham1\Documents\Graham\OpenCVExamples\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 2 unresolved externals

Any advice on what I need to do?????

Graham

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2013-07-16 14:11:01 -0600

berak gravatar image

it probably gets easier to understand, once you split it up in 3 stages:

  • the compiler has to find the code and the includes (yes, opencv\build\include is the right answer here)

  • the linker has to find libraries ( .lib files, not dlls, you're wrong here, the path for that should be: opencv\build\x64\vc12\lib )

  • once your program compiled & linked ok, the exe has to find the dlls ( that's where you need opencv\build\x64\vc11\bin to be on the PATH environment var)

edit flag offensive delete link more

Comments

Thanks for that advice. I have changed the Library Directories to \lib I have checked that Executable Directories correspond to PATH and that it refers to \bin

However, I am still getting the same error

gt324 gravatar imagegt324 ( 2013-07-16 15:33:14 -0600 )edit

ok, if you see "unresolved external symbol", know, that it's a linker error.

in this case, it could not find the constructor/destructor of VideoCapture, and that's in the highgui module..

so, did you add opencv_highgui246.lib to your link libraries ? (opencv_highgui246d.lib for DEBUG mode)

berak gravatar imageberak ( 2013-07-16 15:39:41 -0600 )edit

I can't remember exactly why I did this. I think that it was in the tutorial, but I have a list of all of the .lib files, including the opencv_highgui246d.lib in the list of the Additional dependencies under linker input. I have only configured debug mode

gt324 gravatar imagegt324 ( 2013-07-16 18:13:29 -0600 )edit
0

answered 2013-07-17 00:19:30 -0600

Hello, gt324.

I remembered a lot of me when I started with opencv using Visual Studio 2012, your problem is configuration. You have to import the libraries, archives "lib" and not the "dll", on the other hand, many presonas programmed using the libraries for release to debug, and this brings problems that sometimes keeps us busy for a while :). I advise you to read this tutorial and follow in detail:

http://4someonehelp.blogspot.com/2013/04/install-opencv-245-using-visual-studio.html

I hope you solve.

edit flag offensive delete link more

Comments

The problem with that tutorial is that it starts with a big warning that it only applies to 32 bit machines. Mine is 64. I am wondering if I may do better to try to install the 32 bit version anyway.

gt324 gravatar imagegt324 ( 2013-07-17 04:02:25 -0600 )edit
0

answered 2013-07-17 21:45:19 -0600

Hi, gt324

In the tutorial I gave up in the first few lines give you a link for 64 bit operating systems. Similarly here I leave the link to the 64 bit.

http://4someonehelp.blogspot.in/2013/06/solved-install-opencv-245-using-visual.html

I hope you solve. :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-16 13:55:47 -0600

Seen: 562 times

Last updated: Jul 17 '13