Compile problem for Raspberry Pi 3 with opencv

  • Hello guys, I'm doing a project on Rpi 3, and I use QTcreator to make a GUI application. I also try to use opencv for my code. But the problem: when compiling, error
    *:-1: error: mainwindow.o: undefined reference to symbol '_ZN2cv6imreadERKNS_6StringEi'

    /usr/local/lib/ error: error adding symbols: DSO missing from command line*
    I dont know how to fix it. Anyone has suggestion? Thank you.
    This is my imported libraries in .pro file

    INCLUDEPATH += /usr/local/include
    INCLUDEPATH += /usr/local/include/opencv
    INCLUDEPATH += /usr/local/include/opencv2
    LIBS += -L/usr/local/lib
    LIBS += -lopencv_core
    LIBS += -lopencv_imgproc
    LIBS += -lopencv_highgui
    LIBS += -lopencv_ml
    LIBS += -lopencv_video
    LIBS += -lopencv_features2d
    LIBS += -lopencv_calib3d
    LIBS += -lopencv_objdetect
    LIBS += -lopencv_contrib
    LIBS += -lopencv_legacy
    LIBS += -lopencv_flann
    LIBS += -lopencv_nonfree

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you developing on the RPi3 directly ? Or are you cross-compiling ?

  • I installed Qt and Qtcreator by "apt-get install qt5-default/qtcreator". Qtcreator run successfully without opencv.

  • @SGaist Is it better if I reinstall QT by this guide: ?

  • Lifetime Qt Champion

    You didn't answer my question: are you developing directly on the RPi3 ?

  • @SGaist Yes =D sr I'm a little bit confused

  • Lifetime Qt Champion

    Good then next question, did you build OpenCV yourself ? Or did you install the one from the distribution you have on your Pi ?

  • Lifetime Qt Champion

    You are missing -lopencv_imgcodecs in your .pro file.

  • @SGaist It works, thank you so much. Aw I didnt focus on this mistake.

  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

Log in to reply