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.3k 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.
  • hamzaelaziziH hamzaelazizi

    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 ?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on 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

    hamzaelaziziH 1 Reply Last reply
    1
    • jsulmJ jsulm

      @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.

      hamzaelaziziH Offline
      hamzaelaziziH Offline
      hamzaelazizi
      wrote on 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

      jsulmJ 1 Reply Last reply
      0
      • hamzaelaziziH hamzaelazizi

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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on 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

        hamzaelaziziH 2 Replies Last reply
        0
        • hamzaelaziziH Offline
          hamzaelaziziH Offline
          hamzaelazizi
          wrote on last edited by
          #5
          This post is deleted!
          1 Reply Last reply
          0
          • jsulmJ jsulm

            @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?

            hamzaelaziziH Offline
            hamzaelaziziH Offline
            hamzaelazizi
            wrote on 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
            • jsulmJ jsulm

              @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?

              hamzaelaziziH Offline
              hamzaelaziziH Offline
              hamzaelazizi
              wrote on 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.

              jsulmJ 1 Reply Last reply
              0
              • hamzaelaziziH hamzaelazizi

                @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.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on 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

                hamzaelaziziH 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @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.

                  hamzaelaziziH Offline
                  hamzaelaziziH Offline
                  hamzaelazizi
                  wrote on 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.

                  jsulmJ 1 Reply Last reply
                  0
                  • hamzaelaziziH hamzaelazizi

                    @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.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 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

                    hamzaelaziziH 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @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.

                      hamzaelaziziH Offline
                      hamzaelaziziH Offline
                      hamzaelazizi
                      wrote on 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 ?

                      jsulmJ 1 Reply Last reply
                      0
                      • hamzaelaziziH hamzaelazizi

                        @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 ?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 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

                        hamzaelaziziH 1 Reply Last reply
                        0
                        • jsulmJ jsulm

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

                          hamzaelaziziH Offline
                          hamzaelaziziH Offline
                          hamzaelazizi
                          wrote on last edited by
                          #13

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

                          jsulmJ 1 Reply Last reply
                          0
                          • hamzaelaziziH hamzaelazizi

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

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 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

                            hamzaelaziziH 1 Reply Last reply
                            0
                            • jsulmJ jsulm

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

                              hamzaelaziziH Offline
                              hamzaelaziziH Offline
                              hamzaelazizi
                              wrote on 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 ?

                              jsulmJ 1 Reply Last reply
                              0
                              • hamzaelaziziH hamzaelazizi

                                @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 ?

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 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

                                hamzaelaziziH 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @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.

                                  hamzaelaziziH Offline
                                  hamzaelaziziH Offline
                                  hamzaelazizi
                                  wrote on 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

                                  • Login

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