Qt, OPENCV APPLICATION DEPLOYEMENT ON RASPBERRY PI
-
wrote on 5 May 2022, 12:40 last edited by
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 ?
-
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 ?
@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.
-
@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.
wrote on 5 May 2022, 12:54 last edited by@jsulm So what should i do exactly ? how can i prevent this lib from being deployed ? i really don't get it
-
@jsulm So what should i do exactly ? how can i prevent this lib from being deployed ? i really don't get it
@hamzaelazizi How do you deploy your app?
Can you also dofile /usr/local/lib/libopencv_gapi.so
on Raspi in a terminal and post the output?
-
wrote on 5 May 2022, 13:06 last edited byThis post is deleted!
-
@hamzaelazizi How do you deploy your app?
Can you also dofile /usr/local/lib/libopencv_gapi.so
on Raspi in a terminal and post the output?
wrote on 5 May 2022, 14:18 last edited by@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"
-
@hamzaelazizi How do you deploy your app?
Can you also dofile /usr/local/lib/libopencv_gapi.so
on Raspi in a terminal and post the output?
wrote on 6 May 2022, 07:56 last edited by@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.
-
@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.
@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.
-
@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.
wrote on 6 May 2022, 09:21 last edited by@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.
-
@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.
@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.
-
@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.
wrote on 6 May 2022, 09:35 last edited by@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 ? -
@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 ?@hamzaelazizi Did you already take a look at https://wiki.qt.io/Raspberry_Pi_Beginners_Guide ?
-
@hamzaelazizi Did you already take a look at https://wiki.qt.io/Raspberry_Pi_Beginners_Guide ?
wrote on 6 May 2022, 09:48 last edited by@jsulm no i did not ! should i remove the toolchain i have already installed ?
-
@jsulm no i did not ! should i remove the toolchain i have already installed ?
@hamzaelazizi No, keep it for now, you anyway need a cross compilation tool chain
-
@hamzaelazizi No, keep it for now, you anyway need a cross compilation tool chain
wrote on 6 May 2022, 10:00 last edited by@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 ?
-
@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 ?
@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. -
@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.wrote on 6 May 2022, 10:38 last edited by@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/17