I try to integrate the OpenCV library into my Qt-based project in Visual Studio 2012. I know there exist a lot of other threads to this problem but none solved my linking issues. Here is my setup:
- Windiws 8.1 64-Bit
- Visual Studio 2012 32-Bit
- OpenCV 3.0
- Qt 5.1 32-Bit and Qt Add-In 1.2.3
I downloaded the OpenCV 3.0 Windows package and used CMake and the Visual Studio compiler to build it; I followed this instruction. The build folders look like this: . The .lib and .dll files were generated correctly: Then I followed the instruction on the official OpenCV page and this one and did the following configurations:
- VC++ Directories ‣ "Executable Directories": I added the path to the bin folder which is shown in the third picture
- VC++ Directories ‣ "Library Directories": I added the path to the lib folder shown in the second picture
- C/C++ ‣ General ‣ "Additional Include Directories": here I added the path to the original include folder of the extracted OpenCV package as the build includes folder is empty
- Linker ‣ General ‣ "Additional Library Directories": here I added the path to the lib files
- Linker ‣ Input ‣ "Additional Dependencies": here I listed all libraries like this:
opencv_core300d.lib
opencv_highgui300d.lib
opencv_imgproc300d.lib
opencv_video300d.lib
opencv_calib3d300d.lib
opencv_contrib300d.lib
opencv_features2d300dd.lib
opencv_flann300d.lib
opencv_gpu249d.lib
opencv_legacy300d.lib
opencv_ml300d.lib
opencv_nonfree300d.lib
opencv_objdetect300dd.lib
opencv_ocl300d.lib
opencv_photo249d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencv_ts300d.lib
opencv_videostab300d.lib
I also want to note that I can not change the code generation to /MTd as Qt would not work with that (but that should not be the problem since I build OpenCV activating the option WITH_QT in the CMake configuration)
Additionally I put all .dll files in the same directory as my generated debug .exe (Visual Studio otherwise complained that the .dll could not be found)
When I try to execute a function of the OpenCV lib or only create an object I always get unsolved link errors like this one:
Fehler 2 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""class cv::Mat __cdecl cv::imread(class cv::String const &,int)" (?imread@cv@@YA?AVMat@1@ABVString@1@H@Z)" in Funktion "_main".
or this one
Fehler 2 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall cv::VideoCapture::VideoCapture(void)" (??0VideoCapture@cv@@QAE@XZ)" in Funktion ""void __cdecl loadMovie(class QString)" (?loadMovie@@YAXVQString@@@Z)".
I really would appreciate the help since I have been struggling for one whole week now trying everything I found on the internet.
imread
is placed now. – Mickaopencv_imgcodecs300d.lib
– Micka