How to prepare Qt (qmake) cross compiling on amd64 for armhf (Raspberry Pi)
-
I'm familiar with compiling Qt with no cross-compiling. However, I'd like to create a
qmake
that can be executed on amd64, but generates code for armhf for Raspberry Pis. This is necessary because our Qt-based software is huge and takes at least 4 hours to compile on a Raspberry Pi, while it takes on a desktop 2 minutes. It's a difficult situation.For Ubuntu, there's
qt5-qmake-arm-linux-gnueabihf
, which is exactly what I'm looking for. I couldn't find that for Debian (Raspbian) Stretch. So my question is: Is there a consistent recipe that can be put into production that can be used to produce a cross-compiling version of Qt from amd64 to armhf?Although I found some recipes that claim to do that, but none of them are official, in the sense that they use tricks to work, instead of simply using system tools to create them.
-
Did you see already Qt on Pi and there are some more specifics as well.
-
@SamerAfach in addition to the good links from @koahnig , you may also want to take a look at this cross-compiling guide Qt for Raspberry Pi
-
@Pablo-J.-Rogina @koahnig Thank you for the links. I was able to finally compile it. I compiled 5.11.2 with the configure command:
../${pulldir}/configure -static -no-opengles3 -no-gcc-sysroot -fontconfig -system-freetype -release -debug -no-warnings-are-errors -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot $ROOTFS -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake examples -nomake tests -qt-xcb -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -extprefix ${currpath}/${installdir}
However, there's a problem that anything I compile there and try to run on the same raspberry pi, from which I got the sysroot, I get the error:
failed to open vchiq instance
If I compile the same software on raspberry pi, that doesn't happen. Please advise. Am I doing anything wrong?
-
@SamerAfach said in How to prepare Qt (qmake) cross compiling on amd64 for armhf (Raspberry Pi):
failed to open vchiq instance
Could it be possible that you're using a different user when running the cross-compiled Qt app versus when compiling/running it on the same RPi? If so, this answer may apply to you.
-
@Pablo-J.-Rogina not really. I'm running both with the same user (the only user I have on that rpi).
Could this be some library problem with egl? I'm trying to play with the libraries to fix this. I wanna mention that I don't have a
/opt/vc/lib/libEGL.so
On my amd64 machine. Also I never got any compilation errors, btw. That command I ran before from stack exchange for permissions.
-
@SamerAfach said in How to prepare Qt (qmake) cross compiling on amd64 for armhf (Raspberry Pi):
I wanna mention that I don't have a
/opt/vc/lib/libEGL.soOn my amd64 machine
No, you shouldn't. However, I guess you SHOULD have $ROOTFS/opt/vc/lib/libEGL.so instead.
Please look at step 8 from the guide I referred to regarding creating/populating a sysroot in your host PC.
And please double check the PATH includes /opt/vc/lib when you run the cross-compiled Qt app in your RPi device.
-
@Pablo-J.-Rogina I verified that the new configuration is as you mentioned, and did the links correctly to sysroot and that
/opt/vc/lib
is in the pi where I run the produced executable, but that doesn't help. I did all the steps from the guide also, include relative paths changing. I finally changed the permissions of/dev/vchiq
withchmod a+rw /dev/vchiq
, and that error didn't appear anymore, but no window would open. The application would look like as if it's running, but no GUI shows up at all. No errors, nothing. I don't even know how to start debugging such a problem.Is there a way to do this without OpenGL completely, with
-no-opengl
? I don't need OpenGL in my application. Do I absolutely need EGL?Also, please notice that I'm using Qt statically because I don't want our clients to have to get the whole Qt library. I'm guessing that has nothing to do with the problem.
One more point is that Raspbian uses Qt 5.7.1 by default. I tried to use that version to do the cross compilation and that doesn't work. Apparently Qt didn't support cross-compilation back then?
Please advise on what to do next. I'm not sure how to proceed.
EDIT: I tried both Mobaxterm and VNC to see the window showing up. Both didn't.