Issue with QT and cross-compiling from Mac to Raspbian Stretch(RPi3) - qt

I'm following QT's documentation here to the letter: https://wiki.qt.io/RaspberryPi2EGLFS but I am constantly running into the same issue on my mac on Step 10.
I am running the following command:
./configure -release -opengl es2 -device linux-rasp-pi3-g++ -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 -no-use-gold-linker -v
I get the following error:
Project ERROR: Cannot run compiler '/home/jordan/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++'. Maybe you forgot to setup the environment?
I have been fighting this tooth and nail and I cannot find an answer online, so I'm someone here may have an answer.

The cross-compilation toolchain Raspberry Pi provides is probably built for Linux host systems. You need to use a toolchain built for macOS hosts, such as this one here.

Related

Ubuntu Cross-Compiling QT for Raspberry Pi | ERROR: Unknown command line option 'skip'

I am fairly very new to Ubuntu/Linux and am currently running into an issue with getting an ERROR: Unknown command not found. I am trying configure Qt for cross compilation for a raspberry pi. I have looked up for similar issues but to no avail unfortunately.
The code I am running is as follows
./configure -release -opengl es2 -device linux-rasp-pi3-g++ -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 -qpa eglfs -no-xcb -system-freetype -skip qtwebengine -nomake examples -nomake tools -fontconfig
I need to skip a few things in it but when I run this I get this line
ERROR: Unknown command line option '-skip'.
For some extra info, this is my location when doing so as follows when typing in pwd
/home/usr/raspi/qt-everywhere-src-5.11.3/qtbase
Configure is not recognizing the skip option, because you are running it from qtbase folder. Try to tun configure from the top qt folder.

qt configure issue with cross compilation: device and xplatform

I am trying to cross compile the latest Qt (version 5.9) for the raspberry pi compute module. I am quite new to this but found this guide very helpful: https://visualgdb.com/tutorials/raspberry/qt/embedded/
I followed the instruction but when it comes to configuring qt, I have the following command as suggested in the guide (I have replaced version 5.5 with 5.9):
../qt-everywhere-opensource-src-5.9.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi2-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5
In my case this throws the error that I cannot specify both the xplatform and device parameters. I am new to this and I am not sure which one of the two should be specified!
When you select mkspec for configure you can select a host platform with -platform, or when cross-compiling you can select target platform with -xplatform. When cross-compiling for a specific supported device you select the mkspec with -device. You can give options for the specific device with -device-option flag. When using -device flag you don't use -xplatform flag.
In Qt, there seems to be a device mkspec for Raspberry Pi 2. You can find Qt mkspecs from qtbase module in Qt source tree, e.g. Raspberry Pi 2 mkspec: qt-everywhere-opensource-src-5.9.0/qtbase/mkspecs/devices/linux-rasp-pi2-g++.
There is Raspberry Pi Beginners Guide in Qt wiki which might be helpful. It says you should initially build qtbase and then compile other modules one by one. In the wiki there is an example configure command for Raspberry Pi 2 (in Linux host env) which uses -device and -device-option flags:
./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix /usr/local/qt5pi
make -j 4
sudo make install

Building Qt with OpenSSL on Ubuntu 16.04.1 fails

I have almost spent a week trying to build Qt5.8.0 with OpenSSL on Ubuntu 16.04.1 x64.
First of all I downloaded sources of OpenSSL v1.0.2k. Then I configured it with command
./Configure --prefix=$PWD/dist -shared linux-x86_64
Then I run theese commands one by one:
make depend
make
make install
So I got Openssl installed in /home/user/openssl-OpenSSL_1.0.2k/dist
Then I downloaded Qt from official website, and installed it with sources, so the sources are situated in /home/user/Qt5.8.0/5.8/Src
Then I tried to configure it with command
OPENSSL_LIBS='-L/home/user/openssl-OpenSSL_1_0_2k/dist/lib -lssl -lcrypto' ./configure -prefix /home/user/qt5_static -opensource -confirm-license -release -nomake examples -nomake tests -static -openssl-linked -I /home/user/openssl-OpenSSL_1_0_2k/dist/include/openssl -L /home/user/openssl-OpenSSL_1_0_2k/dist/lib
But got theese errors:
ERROR: Feature 'openssl' was enabled, but the pre-condition '!features.securetransport && tests.openssl' failed.
ERROR: Feature 'openssl-linked' was enabled, but the pre-condition
'features.openssl && libs.openssl' failed.
What am I doing wrong, and how to fix this issue?
Thank you in advance, and sorry for my bad english.
I had same problem when trying to link openSSL statically and found following solution:
1) Install openSSL
sudo apt-get update && sudo apt-get install libssl-dev
2) Configure and build qt from sources, including -openssl-linked option, my example configuration:
/home/someuser/Qt/5.8/Src/configure -c++std c++11 -static -release -platform linux-g++-64 -prefix /home/someuser/Qt/StaticRelease58 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -qt-xcb -make libs -openssl-linked -nomake tools -nomake examples -nomake tests -opensource -confirm-license -skip qtwayland -skip qtwebview -skip qtwebengine -skip qtwebchannel -no-qml-debug
Note that to build QT statically, you also must have installed other packages described here:
http://doc.qt.io/qt-5/linux-requirements.html
http://doc.qt.io/qt-5/linux-deployment.html
P.S. Linking dynamically to openSSL from QT5.8 works fine for me with default setup.

An error building Qt libraries for the raspberry pi linking error

Is there anybody having this error while build qt libraries for raspberry pi 3 ?
/ssd/rpi/rpi-tools2/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld.gold: error: /ssd/rpi/tmp/qt-everywhere-opensource-src-5.7.0/qtbase/lib/libqtpcre.a(pcre16_chartables.o): unknown CPU architecture
I've read this link (https://stackoverflow.com/questions/13626726/an-error-building-qt-libraries-for-the-raspberry-pi#=) , but I can't find any clue on this.
This is what I'm trying..
On ubuntu 16.04, gcc 5.3.1,
mount jessie
sudo mount -o loop,offset=70254592 /ssd/rpi/2016-05-27-raspbian-jessie.img /mnt/rasp-pi-rootfs/
fix library paths
./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ /ssd/rpi/rpi-tools2/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc
export
export RPI_TOOLCHAIN=/ssd/rpi/rpi-tools2/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
export RPI_SYSROOT=/mnt/rasp-pi-rootfs
configure..
./configure -opengl es2 -c++std 11 -device linux-rpi3-g++ -fontconfig -device-option CROSS_COMPILE=$RPI_TOOLCHAIN -sysroot $RPI_SYSROOT -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt57pi -hostprefix /usr/local/qt57pi -v
make
make -j4
Run configure again with the parameter "-no-use-gold-linker".
The problem seems to be related to gold linker with ARMv8. I've changed one Makefile to test, changing "-fuse-ld=gold" to "-fuse-ld=bfd".
The link runs fine.
In qtbase/mkspecs/devices/linux-rpi3-vc4-g++/qmake.conf you can check the comments:
# Example configure command below. We disable using the GNU gold
# linker as it apparently has issues with ARMv8. In the configure
# output check that "EGLFS GBM .......... yes" is present, otherwise
# eglfs will not be functional.
#
# ./configure -release -opengl es2 -device linux-rpi3-vc4-g++ \
# -device-option CROSS_COMPILE=~/raspbian/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- \
# -sysroot ~/raspbian/sysroot \
# -prefix /usr/local/qt5pi -extprefix ~/raspbian/qt5pi -hostprefix ~/raspbian/qt5 \
# -v -nomake examples -nomake tests -no-use-gold-linker

Error when cross compiling Qt 5.0.1 for the Raspberry Pi

I'm trying to cross compile Qt 5.0.1 (latest release at the moment) for my Raspberry Pi. My set up is as follows:
Operating System: Ubuntu 12.04 32-bit
Cross compiler: Built from crosstool-NG program, using the exact instructions found here
Raspberry Pi Operating System: Raspbian Wheezy 2013-02-09 (mounted at /mnt/raspberry-pi-rootfs)
Configure command:
./configure -no-pch -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/home/<myusername>/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- -sysroot /mnt/raspberry-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5-raspberry-pi -v
When I run the configure command, it always fails with the following error:
Could not determine the target architecture!
/mnt/raspberry-pi-rootfs/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
Anyone know what this means?
I have tried the latest pre-built Linaro Toolchain cross compiler from here, and Qt at least builds, but any program compiled with it causes SIGILL (illegal instruction) fault as soon as the program runs up, which I guess is because the pre-built cross compler I used is not targeting the right architecture.
Note:
I am aware cross compiling is fiendishly difficult, but I'd like to understand more about what is going on
I'm not sure what the exact cause of this message was, but I managed to sort out by using a pre-buils toolchain for the Raspberry Pi from here:
https://github.com/raspberrypi/tools

Resources