Building OpenCV 3.0.0 with MS Visual Studio 2012

asked 2014-09-25 15:28:06 -0500

bob h gravatar image

updated 2014-09-25 15:49:54 -0500

berak gravatar image

I am trying to compile OpenCV 3.0.0 (code build with CMake) using Microsoft Visual Studio 2012. I am following the tutorial: http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html . By following the tutorial, I can build the libraries without errors to the directory: C\OpenCV300\build\install (.dlls in the ...\bin\ directory and .lib files in the ...\lib\ directory). However, when I make a new project in Visual Studio and and try to use these libraries for reading/writing images and utilizing my webcam, I get errors, such as the following:

1>OpenCV300_Webcam.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::VideoCapture::read(class cv::_OutputArray const &)" (?read@VideoCapture@cv@@UEAA_NAEBV_OutputArray@2@@Z)

1>OpenCV300_Webcam.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::VideoCapture::isOpened(void)const " (?isOpened@VideoCapture@cv@@UEBA_NXZ)

1>OpenCV300_Webcam.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl cv::VideoCapture::~VideoCapture(void)" (??1VideoCapture@cv@@UEAA@XZ)

1>OpenCV300_Webcam.obj : error LNK2001: unresolved external symbol "public: __cdecl cv::VideoCapture::VideoCapture(int)" (??0VideoCapture@cv@@QEAA@H@Z)

which seem to indicate the libraries are not working correctly. Note that I also downloaded a pre-compiled version of OpenCV 2.4.9 and am able to utilize those just fine. Thus, I would guess I am doing something wrong that is causing the library files to not compile correctly (I am not an expert programmer, and this is the first time I've tried to build a large library like this from the source code).

edit retag flag offensive close merge delete

Comments

did you miss, that VideoCapture in 3.0 is in the videoio module (requiring to link videoio.lib), not in highgui(as in 2.4.9) ?


(hmm, tutorial definitely needs an update)

berak gravatar imageberak ( 2014-09-25 15:47:28 -0500 )edit

Actually, I did miss that. The code will now compile, but when I run it I get an error: "The program can't start because opencv_core300.dll is missing from your computer." Again, I have the .dll files in the \bin\ directory and the .lib file in the \lib\ directory, and I have the Linker Additional Dependencies linking to both, so I'm not sure what the problem is. Also, I can't import the OpenCV 3.0.0 python library that was built (again when I replace with the 2.4.9 version I can import fine into python).

bob h gravatar imagebob h ( 2014-09-25 17:02:08 -0500 )edit
2

Your code is compiled but the program can not find the needed .dll file. Did you add the path to DLL files to the system PATH environment variable?

tuannhtn gravatar imagetuannhtn ( 2014-09-25 23:03:22 -0500 )edit

My path to the the DLL was wrong. Thanks for the suggestion. Both C++ and Python libraries work OK now.

bob h gravatar imagebob h ( 2014-09-26 07:55:46 -0500 )edit