Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Link / Build Error QtCreator 4.10.2, Qt 5.13, OpenCV, Ubuntu 18.04.



  • Hello guys,

    after upgrading my OS to 18.04 (from 16.04) and updating QtCreator / Qt I'm not able to link or include OpenCV in my projects.
    Even old projects, which haven't changed since last time don't work anymore.

    I included the OCV files as usual:

    #include "opencv2/imgproc.hpp"
    #include "opencv2/core.hpp"
    #include "opencv2/highgui.hpp"
    #include "opencv2/opencv.hpp"
    

    and added the linker paths to my pro-file:
    (I double checked these libs and paths, they should be correct and all files are actually there)

    INCLUDEPATH += /usr/local/include/opencv
    LIBS += -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopencv_videoio
    

    Nevertheless I'm getting undefined reference to every OCV related stuff I'm trying to use.
    Starting with

    /usr/local/include/opencv2/core/cvstd.hpp:648: Error: undefined reference to `cv::String::deallocate()'
    

    followed by imgproc-ref errors everytime I want to use imread or anything else.

    The directory permissions dont look wrong as well...

    Anybody got an idea what could went wrong?
    Last time (some time ago) I've coded on this machine there was no error at all and everything worked fine.

    Classic case of "Never change a running system" ;-)

    TIA



  • I still don't know what exactly went wrong, but after I removed all of the OpenCV stuff and re-installed a fresh v4.1, it worked. So even though I checked all lib-files, there must have been something wrong with the linked libs (Pointing to different versions?! Links not working?!, etc.)

    Thanks @SGaist, your answer made me remove everthing and try the OCV version that is provided by Ubuntu 18.04. I got 3.X.X from there... After I removed this version again (because I want a newer one) and installed 4.1 from OCV page, it worked :-)


  • Lifetime Qt Champion

    Hi,

    How did you install OpenCV ?
    What version are you using ?
    What version were you using before ?



  • @SGaist

    Looks like I have two OCV versions installed.... :)
    V.3 and 4.1 (4.1. is the latest)
    Both from github / sourceforge, following the guide from https://opencv.org/
    But all libs are there as v3 and v4.1 version, so it doesnt matter which version is actually in use?!

    I cant remember if I changed something else to make it run (PATH vars?! Further changes in QtCreator?!)


  • Lifetime Qt Champion

    Why not use the version provided directly by Ubuntu ?



  • @SGaist

    Does it make a difference?
    But I will give it a try tomorrow.

    I could swear I've added some additional parameters in the old QtCreator (not the .pro file) to link OCV libs. I've seen the option to set a Kit, but I can't find where I can edit things like that in the newer QtCreator versions. Normally I work with 4.7.X on Windows.
    (The QtCreator version on that linux machine was the one you can download from Ubuntu App Store. So not up-to-date. Actually quite outdated... 3.x.x, if I'm not mistaken, but it worked with OCV)



  • I still don't know what exactly went wrong, but after I removed all of the OpenCV stuff and re-installed a fresh v4.1, it worked. So even though I checked all lib-files, there must have been something wrong with the linked libs (Pointing to different versions?! Links not working?!, etc.)

    Thanks @SGaist, your answer made me remove everthing and try the OCV version that is provided by Ubuntu 18.04. I got 3.X.X from there... After I removed this version again (because I want a newer one) and installed 4.1 from OCV page, it worked :-)