I have a CentOS host which should be used to develop Qt applications (version 5.12.8) for a Raspberry Pi. I use the following Raspberry Pi setup:
$ cat /proc/cpuinfo
...
model name : ARMv7 Processor rev 4 (v7l)
...
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
The Raspberry Pi is prepared with the following script:
sudo apt-get update
sudo apt-get -y build-dep qt5-qmake
sudo apt-get -y build-dep libqt5gui5
sudo apt-get -y build-dep libqt5webengine-data
sudo apt-get -y build-dep libqt5webkit5
sudo apt-get -y install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver
sudo mkdir /usr/local/RaspberryQt
sudo chown -R pi:pi /usr/local/RaspberryQt
sudo mkdir -p /root/.ssh
sudo chmod 700 /root/.ssh
sudo mkdir -p /home/pi/.ssh
sudo chmod 700 /home/pi/.ssh
And for the host I use this script:
DEVICE=linux-rasp-pi3-g++
IP=...
CORES=4
DIRECTORY=/opt/RaspberryQt
COMPILER_PATH=/opt/Toolchain/RaspberryPi
Red="\033[0;31m"
Green="\033[0;32m"
Reset="\033[0m"
Yellow="\033[0;33m"
Cyan="\033[0;36m"
echo -e ${Yellow}"Install packages..."${Reset}
sudo apt-get update
sudo apt-get -y install gcc git bison python gperf pkg-config gdb-multiarch qt5-default
echo -e ${Yellow}"Create directories..."${Reset}
sudo mkdir -p ${DIRECTORY}/log ${DIRECTORY}/build
sudo mkdir -p ${COMPILER_PATH}/sysroot ${COMPILER_PATH}/sysroot/usr ${COMPILER_PATH}/sysroot/opt
cd ${DIRECTORY}
sudo chown -R 1000:1000 ${DIRECTORY}
sudo chown -R 1000:1000 ${COMPILER_PATH}
echo -e ${Yellow}"Generate SSH keys..."${Reset}
ssh-keygen -t rsa -C root@${IP} -P "" -f ~/.ssh/rpi_root_id_rsa
ssh-keygen -t rsa -C pi@${IP} -P "" -f ~/.ssh/rpi_pi_id_rsa
cat ~/.ssh/rpi_root_id_rsa.pub | ssh root@${IP} 'cat >> .ssh/authorized_keys && chmod 640 .ssh/authorized_keys'
cat ~/.ssh/rpi_pi_id_rsa.pub | ssh pi@${IP} 'cat >> .ssh/authorized_keys && chmod 640 .ssh/authorized_keys'
echo -e ${Yellow}"Download toolchain..."${Reset}
cd ${COMPILER_PATH}
git clone https://github.com/raspberrypi/tools
cd ${DIRECTORY}
echo -e ${Yellow}"Download Qt..."${Reset}
wget https://download.qt.io/archive/qt/5.12/5.12.8/single/qt-everywhere-src-5.12.8.tar.xz
echo -e ${Yellow}"Download Python script..."${Reset}
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
sudo chmod +x sysroot-relativelinks.py
tar xf qt-everywhere-src-5.12.8.tar.xz
cp -R qt-everywhere-src-5.12.8/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.12.8/qtbase/mkspecs/linux-arm-gnueabihf-g++
sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.12.8/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf
cd ${COMPILER_PATH}
echo -e ${Yellow}"Download /lib..."${Reset}
rsync -avz root@${IP}:/lib sysroot | tee ${DIRECTORY}/log/copy_lib.log
echo -e ${Yellow}"Download /usr/include..."${Reset}
rsync -avz root@${IP}:/usr/include sysroot/usr | tee ${DIRECTORY}/log/copy_usr_include.log
echo -e ${Yellow}"Download /usr/lib..."${Reset}
rsync -avz root@${IP}:/usr/lib sysroot/usr | tee ${DIRECTORY}/log/copy_usr_lib.log
echo -e ${Yellow}"Download /opt/vc..."${Reset}
rsync -avz root@${IP}:/opt/vc sysroot/opt | tee ${DIRECTORY}/log/copy_opt_vc.log
echo -e ${Yellow}"Change symlinks..."${Reset}
ln -s sysroot/opt/vc/lib/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
ln -s sysroot/opt/vc/lib/libEGL.so sysroot/opt/vc/lib/libEGL.so.1
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/opt/vc/lib/libGLESv2.so.2
${DIRECTORY}/sysroot-relativelinks.py sysroot
echo -e ${Yellow}"Configure Qt..."${Reset}
cd ${DIRECTORY}/build
../qt-everywhere-src-5.12.8/configure -opengl es2 -device ${DEVICE} -device-option CROSS_COMPILE=${COMPILER_PATH}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ${COMPILER_PATH}/sysroot -prefix /usr/local/RaspberryQt -opensource -confirm-license -no-gbm -skip qtscript -nomake tests -nomake examples -make libs -pkg-config -no-use-gold-linker -v | tee ${DIRECTORY}/log/config.log
echo -e ${Yellow}"Build Qt..."${Reset}
make -j${CORES} | tee ${DIRECTORY}/log/make.log
make install | tee ${DIRECTORY}/log/install.log
echo -e ${Yellow}"Clean..."${Reset}
sudo rm -r ${DIRECTORY}/build
sudo rm -r ${DIRECTORY}/sysroot-relativelinks.py
sudo rm -r ${DIRECTORY}/qt-everywhere-src-5.12.8
sudo rm ${DIRECTORY}/qt-everywhere-src-5.12.8.tar.xz
echo -e ${Yellow}"Upload to Raspberry Pi..."${Reset}
cd ${DIRECTORY}
rsync -avz ${COMPILER_PATH}/sysroot/usr/local/RaspberryQt pi@${IP}:/usr/local | tee ${DIRECTORY}/log/copy_RaspberryQt.log
The build process has finished successfully and I can create a new kit in the Qt Creator to compile the code for the Raspberry Pi.
Now I create a new Qt project with this kit and compile it. The compilation finished successfully too, but I got the following error in the Qt Creator when I want to run the application over SSH:
Could not initialize egl display
But I can copy the application via SCP on the Raspberry Pi to run it locally.
So what is that error and how can I fix it to run the application from my CentOS host?
sudo ln -s libbrcmEGL.so libEGL.so.1
,sudo ln -s libbrcmGLESv2.so libGLESv2.so.2
and addingexport LD_LIBRARY_PATH=/opt/vc/lib
to mybashrc
it works