Wednesday, April 20, 2022

OpenCV with Qt creator

K asked for pointers for this issue - I am trying to integrate OpenCV into the C++ code that I wrote for gamma acquisition. I am facing a problem while integrating it into the software Qt Creator. The headers are included without any errors, but when I initialize an empty matrix it returns "undefined reference to 'cv::Mat::~Mat()'". 

My reply was - 

"Undefined reference in the linking process doesn't mean, that it can't find the declaration in the header file, it means that it cant find the definition/implementation in any of the provided object files."

So the issue is most probably due to some path issue in the Makefile - it depends on what you are using to build the project. If you are using qt creator, then it would be qmake.

The easiest way to solve this would be perhaps a google search on getting started with OpenCV and QT creator.
Perhaps
if you are using windows.

This is an old version for opencv 3 on ubuntu,
but you may get some ideas from it.

He finally solved it himself - "I could link the library and use its functions now. I believe there are a lot of ways to link the library and I figured one way that worked for me.

I have discussed the way I solved it here 
so that it will be helpful to whoever compiles the OpenCV with Mingw 32-bit in Qt Creator."

So, in short, he "had to link the libraries by right-clicking on the project folder on the left-sidebar, selecting Add Libraries and choosing the External Libraries option (added one by one).

win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_core320.dll
win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_highgui320.dll
win32: LIBS += -LD:/opencv-build/install/x86/mingw/lib/ -llibopencv_imgcodecs320.dll 
INCLUDEPATH += D:/opencv-build/install/include
DEPENDPATH += D:/opencv-build/install/include

////NOTE: imgcodecs library is required for imread to work//////

No comments:

Post a Comment