Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QT 5.12.3, OpenCV 3.4.3, Rasberry Pi 3B+, Cross-Compilation failure

QT 5.12.3, OpenCV 3.4.3, Rasberry Pi 3B+, Cross-Compilation failure

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
qt5.12.3raspberry pi 3bopencv
2 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris1092387456
    wrote on 31 Jul 2019, 13:20 last edited by
    #1

    I recently install QT 5.12.3 for cross compilation on a Raspberry Pi 3B+ running Rasbian Stretch, using this [https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/] guide. Before this I installed OpenCV 3.4.3 using this [https://github.com/jayrambhia/Install-OpenCV] script from Github.

    I have everything set up and I tested the cross compilation without using the OpenCV libraries. Then when I attempt to compile something that uses an OpenCV function the compiler tells me that there are undefined references to OpenCV functions. I am unsure of the reason for why it is failing during compilation. I have included the relavant portiong of my code below

    Could it be related to the way I compiled the OpenCV libraries? In the script the cmake command has the WITH_QT=ON flag.

    Qt recognizes the OpenCV functions, as they appear in the dropdown as I type them in. Has anyone experienced this before?

    I am including the OpenCV libraries in the .pro file like this:

    INCLUDEPATH += "/usr/local/include"
    LIBS += -L/usr/local/lib/libopencv_highgui.so
    LIBS += -L/usr/local/lib/libopencv_core.so
    LIBS += -L/usr/local/lib/libopencv_features2d.so
    LIBS += -L/usr/local/lib/libopencv_flann.so
    LIBS += -L/usr/local/lib/libopencv_imgcodecs.so
    LIBS += -L/usr/local/lib/libopencv_imgproc.so
    LIBS += -L/usr/local/lib/libopencv_objdetect.so
    LIBS += -L/usr/local/lib/libopencv_photo.so
    LIBS += -L/usr/local/lib/libopencv_shape.so
    LIBS += -L/usr/local/lib/libopencv_stitching.so
    LIBS += -L/usr/local/lib/libopencv_superres.so
    LIBS += -L/usr/local/lib/libopencv_video.so
    LIBS += -L/usr/local/lib/libopencv_videoio.so
    

    In the mainwindow.cpp file the OpenCV functions I used are:

    void MainWindow_QTt::on_pushButton_2_clicked()
    {
            namedWindow(window2,WINDOW_NORMAL);
            resizeWindow(window2, 240, 100);
    }
    

    The compiler output is this:

    /home/qt/Code/QT/build-QT_Test-RPi_Server-Debug/../QT_Test/mainwindow_qtt.cpp:50: undefined reference to `cv::namedWindow(cv::String const&, int)'
    /home/qt/Code/QT/build-QT_Test-RPi_Server-Debug/../QT_Test/mainwindow_qtt.cpp:51: undefined reference to `cv::resizeWindow(cv::String const&, int, int)'
    mainwindow_qtt.o: In function `cv::String::String(char const*)':
    /usr/local/include/opencv2/core/cvstd.hpp:602: undefined reference to `cv::String::allocate(unsigned int)'
    mainwindow_qtt.o: In function `cv::String::~String()':
    /usr/local/include/opencv2/core/cvstd.hpp:648: undefined reference to `cv::String::deallocate()'
    

    Thank you for your help.

    P 1 Reply Last reply 31 Jul 2019, 13:56
    0
    • C Chris1092387456
      31 Jul 2019, 13:20

      I recently install QT 5.12.3 for cross compilation on a Raspberry Pi 3B+ running Rasbian Stretch, using this [https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/] guide. Before this I installed OpenCV 3.4.3 using this [https://github.com/jayrambhia/Install-OpenCV] script from Github.

      I have everything set up and I tested the cross compilation without using the OpenCV libraries. Then when I attempt to compile something that uses an OpenCV function the compiler tells me that there are undefined references to OpenCV functions. I am unsure of the reason for why it is failing during compilation. I have included the relavant portiong of my code below

      Could it be related to the way I compiled the OpenCV libraries? In the script the cmake command has the WITH_QT=ON flag.

      Qt recognizes the OpenCV functions, as they appear in the dropdown as I type them in. Has anyone experienced this before?

      I am including the OpenCV libraries in the .pro file like this:

      INCLUDEPATH += "/usr/local/include"
      LIBS += -L/usr/local/lib/libopencv_highgui.so
      LIBS += -L/usr/local/lib/libopencv_core.so
      LIBS += -L/usr/local/lib/libopencv_features2d.so
      LIBS += -L/usr/local/lib/libopencv_flann.so
      LIBS += -L/usr/local/lib/libopencv_imgcodecs.so
      LIBS += -L/usr/local/lib/libopencv_imgproc.so
      LIBS += -L/usr/local/lib/libopencv_objdetect.so
      LIBS += -L/usr/local/lib/libopencv_photo.so
      LIBS += -L/usr/local/lib/libopencv_shape.so
      LIBS += -L/usr/local/lib/libopencv_stitching.so
      LIBS += -L/usr/local/lib/libopencv_superres.so
      LIBS += -L/usr/local/lib/libopencv_video.so
      LIBS += -L/usr/local/lib/libopencv_videoio.so
      

      In the mainwindow.cpp file the OpenCV functions I used are:

      void MainWindow_QTt::on_pushButton_2_clicked()
      {
              namedWindow(window2,WINDOW_NORMAL);
              resizeWindow(window2, 240, 100);
      }
      

      The compiler output is this:

      /home/qt/Code/QT/build-QT_Test-RPi_Server-Debug/../QT_Test/mainwindow_qtt.cpp:50: undefined reference to `cv::namedWindow(cv::String const&, int)'
      /home/qt/Code/QT/build-QT_Test-RPi_Server-Debug/../QT_Test/mainwindow_qtt.cpp:51: undefined reference to `cv::resizeWindow(cv::String const&, int, int)'
      mainwindow_qtt.o: In function `cv::String::String(char const*)':
      /usr/local/include/opencv2/core/cvstd.hpp:602: undefined reference to `cv::String::allocate(unsigned int)'
      mainwindow_qtt.o: In function `cv::String::~String()':
      /usr/local/include/opencv2/core/cvstd.hpp:648: undefined reference to `cv::String::deallocate()'
      

      Thank you for your help.

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 31 Jul 2019, 13:56 last edited by
      #2

      @chris1092387456 could it be possible you have mixed Qt versions from the one you cross-compiled and the one it's used by the OpenCV install script you used.

      Assuming you run Ubuntu/opencv_latest.sh which in turn calls opencv_install.sh and then dependencies.sh, there are some apt-get install calls, so you''ll end up having pre-built Qt libraries along with your cross-compiled ones...

      function install_dependency {
          echo "--- Installing dependency: $1"
          sudo apt-get -y install $1
      }
      ...
      install_dependency libqt5x11extras5
      install_dependency libqt5opengl5
      install_dependency libqt5opengl5-dev
      

      So may I suggest to start from scratch?

      First I'd follow the mechatronics guide to cross-compile and deploy Qt in the RPi device.

      Then I'd follow this guide to cross compile the latest version of OpenCV for Raspberry Pi. As you'll use WITH_QT=ON flag I guess, please adjust the paths in the CMake script(s) to use the cross-compiled Qt version in your host PC.

      And also use the correct path for cross-compiled OpenCV in your .pro file. As example, the following doesn't look good to me:

      LIBS += -L/usr/local/lib/libopencv_highgui.so
      

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0

      2/2

      31 Jul 2019, 13:56

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved