我尝试将OpenCV库集成到我在Visual Studio 2012中基于Qt的项目中。我知道还有很多其他线程可以解决此问题,但没有一个解决了我的链接问题。这是我的设置:
我下载了OpenCV 3.0 Windows软件包,并使用CMake和Visual Studio编译器进行了构建。我遵循了这条指令。构建文件夹如下所示:。在的.lib和.dll文件被正确地产生:然后我跟着官方的OpenCV上的说明页面,这一个,做了以下配置:
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.
The problem is, that the provided link How to build applications with OpenCV inside the Microsoft Visual Studio
is for OpenCV 2.4.11 where libraries were managed a little bit different.
From OpenCV 3.0 on, opencv_highgui lib is split to different sub-libraries concerning VideoCapture, image reading and other stuff. As you can see in your screenshot, there are other libs, which you didn't add yet to your project, e.g. opencv_imgcodecs300d.lib
and opencv_videoio300d.lib
Try to add all those libraries. If that works, and if you want to reduce dependencies, you can remove libraries until linker fails.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句