Unsolved Crosscompiling qt binaries for working in Raspberry Pi
-
Hi, everyone my search for some expert in area goes as follows:
I know how to Crosscompile qt projects for Raspberry Pi deployment on linux, you've got some binary executables on a host A architecture (qmake,moc) that produce makefiles that produce executables and bind in B architecture (from /libs /qml and sysroot) and that once deployed run and link to some standard path. However..... what I want to do is to compile all qtbase module to run in raspberry pi so that /bin qmake, moc... binaries can be called from raspberry pi QtCreator and generate binaries nonetheless I am not clear if that is possible with the configure script.I have changed values from linux-arm-gnueabi-g++ mkspecs to use my linux-arm-gnueabihf-g++ and other crosscompiler tools for raspberry pi and used the following configure options for platforms:
-platform linux-arm-gnueabi-g++ -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=/home/paul/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot /home/paul/raspi/sysroot and so on.
And the following dirs for installing and looking for libraries at runtime:
-prefix /usr/local/qt5pi/ -extprefix /home/paul/Qt/5.11.0/Arm -hostprefix /home/paul/Qt/5.11.0/Arm/I was able to create a qmake version that didn't worked in my A host machine and that worked in my raspberry pi, but as soon as it was created I got the message:
./configure: 860: ./configure: /home/paul/Qt/5.11.0/Src/qtbase/bin/qmake: Exec format error after entering creating qmake which by all means I didn't have moc and other /bin binaries . My first impression was that getting any further was not possibly but then I read:"-external-hostbindir <path> ... Path to Qt tools built for this machine.
Use this when -platform does not match the current
system, i.e., to make a Canadian Cross Build.
"
So I wanted to know if this kind of cross compiling is possible in any way as my platform does not match my current system and if so what the necessary options in the configure files are for this.Regards
-
Yea you can build on a host machine for a target machine. That's what cross compiling is. Unless I'm misunderstanding this.
Something like:
./configure -release -opengl es2 -device <rpi-version> -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v
The -sysroot stuff is what tells the compiler to find the binaries for the target system to be used in the build.
I may be misunderstanding this though ...
-
@ambershark Hi! Thanks for answering, that example you show is what I have already done what this does is that it creates a qmake version for crosscompiling qt projects but I don't want to do that, what I want is to compile qmake and everything from my machine for being executed in the raspberry pi and not ever in the host.
I want to develop with the IDE inside the raspberry Pi in qt 5.11.0 (which discards linux repositories) and compiling inside the pi may take up to 40 hours
-
@PaulMax Oh I see, that should be possible. I haven't done it, but you basically just need to setup a toolchain for cross compiling Qt. You would still need a sysroot that had the proper binaries for the target system.
I know how I would do it with cmake but I'm not sure how to do it with the configure/qmake build system for Qt itself. It should definitely be possible but I'll let someone with some more specific make/qmake knowledge with cross compiling come in here and guide you a bit. :)
I feel like I've helped someone or seen someone who did it in the past on these forums. It was quite a while back though. And I could be remembering wrong.
-
I think this question is best asked at the Interest mailing list which is monitored by the developers.
Regards
-
@ambershark Well I haven't found any information on the web so could you please show how would you do it with cmake?
-
@PaulMax Well for instance, here is an ARM-v7 toolchain that I use in a project in order to build binaries for that system:
set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_C_COMPILER arm-poky-linux-gnueabi-gcc ) set(CMAKE_CXX_COMPILER arm-poky-linux-gnueabi-g++ ) include_directories(SYSTEM /opt/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include) link_directories(/opt/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/lib) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") set(TOOLCHAIN_C_FLAGS "-feliminate-unused-debug-types -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi") set(TOOLCHAIN_CXX_FLAGS "-feliminate-unused-debug-types -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/poky/1.7/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi")
Then I would use that in a build like so:
$ mkdir build $ cd build $ cmake -DCMAKE_TOOLCHAIN_FILE=../armv7-toolchain.cmake .. $ make -j12
The resulting binaries from that would only run and work on the ARM system. You could do something similar but with the full build of Qt.
Then everything from qmake down to the libs would be built for the target architecture and could be run on your Pi after having been built on your desktop.
I don't know off the top of my head how to do this specifically for Qt though. Hopefully my cmake stuff helps. I'm not much of qmake user these days since I've found cmake to be about 10x better. :) I'm almost positive I've seen instructions for this in qmake somewhere on the web before. I know you're definitely not the first to want to do this or ask about it. I just can't remember where I saw it. :/
-
http://lists.qt-project.org/pipermail/interest/2018-July/030491.html is the thread on the mailing list.