Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI
Forum Updated to NodeBB v4.3 + New Features

Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 2 Posters 1.2k 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.
  • H Offline
    H Offline
    hamzaelazizi
    wrote on 5 May 2022, 12:40 last edited by
    #1

    Hello everyone, i'm currently trying to link my OpenCV library with my Qt creator, in order to make a cross-compiled application, that will allow me to open a picture stored on my Raspi and display it on my Raspi.
    So, the application is built on my Ubuntu host machine and then compiled on my Raspi.
    I've already established a toolchain for cross-compilation and it's working as it should, but whenever i try to to deploy this OpenCV test application i get this error when building : "/usr/local/lib/libopencv_gapi.so:-1: error: file not recognized: file format not recognized"

    Here's my .pro code :

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt
    
    
    INCLUDEPATH += /usr/local/include/opencv4
    
    LIBS += `pkg-config --cflags --libs opencv4`
    
    
    SOURCES += \
            main.cpp
    

    Can u help me out with this ?

    J 1 Reply Last reply 5 May 2022, 12:44
    0
    • H hamzaelazizi
      5 May 2022, 12:40

      Hello everyone, i'm currently trying to link my OpenCV library with my Qt creator, in order to make a cross-compiled application, that will allow me to open a picture stored on my Raspi and display it on my Raspi.
      So, the application is built on my Ubuntu host machine and then compiled on my Raspi.
      I've already established a toolchain for cross-compilation and it's working as it should, but whenever i try to to deploy this OpenCV test application i get this error when building : "/usr/local/lib/libopencv_gapi.so:-1: error: file not recognized: file format not recognized"

      Here's my .pro code :

      TEMPLATE = app
      CONFIG += console c++11
      CONFIG -= app_bundle
      CONFIG -= qt
      
      
      INCLUDEPATH += /usr/local/include/opencv4
      
      LIBS += `pkg-config --cflags --libs opencv4`
      
      
      SOURCES += \
              main.cpp
      

      Can u help me out with this ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 5 May 2022, 12:44 last edited by
      #2

      @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

      So, the application is built on my Ubuntu host machine and then compiled on my Raspi.

      This is not clear: if you cross-compile your app there is no need to build it on Raspi.

      ""/usr/local/lib/libopencv_gapi.so:-1: error: file not recognized: file format not recognized"" - this means that the library was built for wrong architecture (I guess x86). You're probably deploying the wrong libopencv_gapi.so. If you're using a sysroot for cross compalation there should be no need to deploy this lib - it should already be on your device.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply 5 May 2022, 12:54
      1
      • J jsulm
        5 May 2022, 12:44

        @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

        So, the application is built on my Ubuntu host machine and then compiled on my Raspi.

        This is not clear: if you cross-compile your app there is no need to build it on Raspi.

        ""/usr/local/lib/libopencv_gapi.so:-1: error: file not recognized: file format not recognized"" - this means that the library was built for wrong architecture (I guess x86). You're probably deploying the wrong libopencv_gapi.so. If you're using a sysroot for cross compalation there should be no need to deploy this lib - it should already be on your device.

        H Offline
        H Offline
        hamzaelazizi
        wrote on 5 May 2022, 12:54 last edited by
        #3

        @jsulm So what should i do exactly ? how can i prevent this lib from being deployed ? i really don't get it

        J 1 Reply Last reply 5 May 2022, 12:56
        0
        • H hamzaelazizi
          5 May 2022, 12:54

          @jsulm So what should i do exactly ? how can i prevent this lib from being deployed ? i really don't get it

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 May 2022, 12:56 last edited by
          #4

          @hamzaelazizi How do you deploy your app?
          Can you also do

          file /usr/local/lib/libopencv_gapi.so
          

          on Raspi in a terminal and post the output?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 2 Replies Last reply 5 May 2022, 14:18
          0
          • H Offline
            H Offline
            hamzaelazizi
            wrote on 5 May 2022, 13:06 last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • J jsulm
              5 May 2022, 12:56

              @hamzaelazizi How do you deploy your app?
              Can you also do

              file /usr/local/lib/libopencv_gapi.so
              

              on Raspi in a terminal and post the output?

              H Offline
              H Offline
              hamzaelazizi
              wrote on 5 May 2022, 14:18 last edited by
              #6

              @jsulm I deploy my application from my Qt Creator on the Ubuntu host machine, I'm not building on the Raspi.
              The application doesn't even build on the host machine, there's no deployment yet.

              When i run the command u gave me, it says "No such file or directory"

              1 Reply Last reply
              0
              • J jsulm
                5 May 2022, 12:56

                @hamzaelazizi How do you deploy your app?
                Can you also do

                file /usr/local/lib/libopencv_gapi.so
                

                on Raspi in a terminal and post the output?

                H Offline
                H Offline
                hamzaelazizi
                wrote on 6 May 2022, 07:56 last edited by
                #7

                @jsulm Quick update, i've ran this command: "file /usr/local/lib/libopencv_gapi.so.4.5.5" in the Ubuntu host terminal and i've got this "file /usr/local/lib/libopencv_gapi.so.4.5.5
                /usr/local/lib/libopencv_gapi.so.4.5.5: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=47f4a526d8349d928efb8a53cae8e4731988f76b, with debug_info, not stripped
                ".

                I know that the problem is that the architecture is for x86-64 and not ARM, and i honestly don't know how to change that

                I still haven't managed to solve this issue.

                J 1 Reply Last reply 6 May 2022, 08:53
                0
                • H hamzaelazizi
                  6 May 2022, 07:56

                  @jsulm Quick update, i've ran this command: "file /usr/local/lib/libopencv_gapi.so.4.5.5" in the Ubuntu host terminal and i've got this "file /usr/local/lib/libopencv_gapi.so.4.5.5
                  /usr/local/lib/libopencv_gapi.so.4.5.5: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=47f4a526d8349d928efb8a53cae8e4731988f76b, with debug_info, not stripped
                  ".

                  I know that the problem is that the architecture is for x86-64 and not ARM, and i honestly don't know how to change that

                  I still haven't managed to solve this issue.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 6 May 2022, 08:53 last edited by
                  #8

                  @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

                  Quick update, i've ran this command

                  You need to run this command on RaspberryPi, not your host.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply 6 May 2022, 09:21
                  1
                  • J jsulm
                    6 May 2022, 08:53

                    @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

                    Quick update, i've ran this command

                    You need to run this command on RaspberryPi, not your host.

                    H Offline
                    H Offline
                    hamzaelazizi
                    wrote on 6 May 2022, 09:21 last edited by
                    #9

                    @jsulm May ask why should i run it on the Raspberry Pi ? tho i have done so and this what i got : "cannot open /usr/local/lib/libopencv_gapi.so (No such file or directory).

                    I haven't actually installed OpenCV on my Raspi. I installed it on the host machine and tried to include it in Qt Creator.

                    J 1 Reply Last reply 6 May 2022, 09:26
                    0
                    • H hamzaelazizi
                      6 May 2022, 09:21

                      @jsulm May ask why should i run it on the Raspberry Pi ? tho i have done so and this what i got : "cannot open /usr/local/lib/libopencv_gapi.so (No such file or directory).

                      I haven't actually installed OpenCV on my Raspi. I installed it on the host machine and tried to include it in Qt Creator.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 6 May 2022, 09:26 last edited by
                      #10

                      @hamzaelazizi Ok, let's start from the beginning. You are doing cross compilation, right? In that case /usr/local/lib/libopencv_gapi.so has to be ARM version. According to the file output it is x86. That means you do not have cross compiled version of that lib. Please first crosscompile it or get it on your RaspberryPi and then update your sysroot to include it there.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      H 1 Reply Last reply 6 May 2022, 09:35
                      1
                      • J jsulm
                        6 May 2022, 09:26

                        @hamzaelazizi Ok, let's start from the beginning. You are doing cross compilation, right? In that case /usr/local/lib/libopencv_gapi.so has to be ARM version. According to the file output it is x86. That means you do not have cross compiled version of that lib. Please first crosscompile it or get it on your RaspberryPi and then update your sysroot to include it there.

                        H Offline
                        H Offline
                        hamzaelazizi
                        wrote on 6 May 2022, 09:35 last edited by
                        #11

                        @jsulm i honestly don't know how to crosscompile it ! when i was trying to install the toolchain to cross compile and deploy my Qt applications on the RaspberryPi, i spent 8 days so i really don't want to mess it up.

                        Also, how can i update my sysroot and include it there ?
                        Do i need to install OpenCV on my RaspberryPi too ?

                        J 1 Reply Last reply 6 May 2022, 09:37
                        0
                        • H hamzaelazizi
                          6 May 2022, 09:35

                          @jsulm i honestly don't know how to crosscompile it ! when i was trying to install the toolchain to cross compile and deploy my Qt applications on the RaspberryPi, i spent 8 days so i really don't want to mess it up.

                          Also, how can i update my sysroot and include it there ?
                          Do i need to install OpenCV on my RaspberryPi too ?

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 6 May 2022, 09:37 last edited by
                          #12

                          @hamzaelazizi Did you already take a look at https://wiki.qt.io/Raspberry_Pi_Beginners_Guide ?

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          H 1 Reply Last reply 6 May 2022, 09:48
                          0
                          • J jsulm
                            6 May 2022, 09:37

                            @hamzaelazizi Did you already take a look at https://wiki.qt.io/Raspberry_Pi_Beginners_Guide ?

                            H Offline
                            H Offline
                            hamzaelazizi
                            wrote on 6 May 2022, 09:48 last edited by
                            #13

                            @jsulm no i did not ! should i remove the toolchain i have already installed ?

                            J 1 Reply Last reply 6 May 2022, 09:50
                            0
                            • H hamzaelazizi
                              6 May 2022, 09:48

                              @jsulm no i did not ! should i remove the toolchain i have already installed ?

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 6 May 2022, 09:50 last edited by
                              #14

                              @hamzaelazizi No, keep it for now, you anyway need a cross compilation tool chain

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              H 1 Reply Last reply 6 May 2022, 10:00
                              0
                              • J jsulm
                                6 May 2022, 09:50

                                @hamzaelazizi No, keep it for now, you anyway need a cross compilation tool chain

                                H Offline
                                H Offline
                                hamzaelazizi
                                wrote on 6 May 2022, 10:00 last edited by
                                #15

                                @jsulm So i have to figure out a way to cross compile that library with the toolchain i have currently, correct ? do you have any idea how i can do that ? how to cross compile something specific such as a library ?

                                J 1 Reply Last reply 6 May 2022, 10:03
                                0
                                • H hamzaelazizi
                                  6 May 2022, 10:00

                                  @jsulm So i have to figure out a way to cross compile that library with the toolchain i have currently, correct ? do you have any idea how i can do that ? how to cross compile something specific such as a library ?

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 6 May 2022, 10:03 last edited by
                                  #16

                                  @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

                                  So i have to figure out a way to cross compile that library with the toolchain i have currently

                                  Not if you can install it on RaspberryPi. Because then it is enough to sync your sysroot.
                                  In case of RaspberryPi the sysroot can be simply the SD card from your RaspberryPi mounted in a folder.
                                  So, install OpenCV libs you need and their dev packages on RaspberryPi using apt, then you should be able to cross compile your app.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  H 1 Reply Last reply 6 May 2022, 10:38
                                  0
                                  • J jsulm
                                    6 May 2022, 10:03

                                    @hamzaelazizi said in Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI:

                                    So i have to figure out a way to cross compile that library with the toolchain i have currently

                                    Not if you can install it on RaspberryPi. Because then it is enough to sync your sysroot.
                                    In case of RaspberryPi the sysroot can be simply the SD card from your RaspberryPi mounted in a folder.
                                    So, install OpenCV libs you need and their dev packages on RaspberryPi using apt, then you should be able to cross compile your app.

                                    H Offline
                                    H Offline
                                    hamzaelazizi
                                    wrote on 6 May 2022, 10:38 last edited by
                                    #17

                                    @jsulm I will do so, and try to install OpenCV on my RaspberryPi, hopefully it'll work !

                                    What i'm truely concerened about is that it shows me this error while building the project on the host machine, it hasn't even started deploying it on the RaspberryPi ! But i will try your suggestion regardless, hopefully it'll fix the issue. Thank you !

                                    1 Reply Last reply
                                    0

                                    1/17

                                    5 May 2022, 12:40

                                    • Login

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