raspberry QT/QML cross compile

http://ulasdikme.com/projects/raspberry/Qt_for_raspberrypi.php

/*

rsync -avz -e 'ssh -p 15001' root@procontrol.top:/lib sysroot
        
rsync -avz -e 'ssh -p 15001' root@procontrol.top:/usr/include sysroot/usr
        
rsync -avz -e 'ssh -p 15001' root@procontrol.top:/usr/lib sysroot/usr
        
rsync -avz -e 'ssh -p 15001' root@procontrol.top:/opt/vc sysroot/opt
        
rsync -avz sysroot/usr/local/qt5pi -e 'ssh -p 15001' root@procontrol.top:/usr/local

docker run -p 6080:80 -p 5900:5900 -e VNC_PASSWORD=hach123456 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc

        

*/

 

If You want to build Qt5 development environmet for raspberry pi then you are in the right place. In this short tutorial you can build your Qt5 for raspberry pi. I used ubuntu-18.04-desktop-amd64 and rasp image is 2018-06-27-raspbian-stretch. For old images something can be different. If you have any trouble, then let me know I can help you.

Qt is a framework. What is framework ? Framework is a platform which includes several tools that makes your life easier. For example GUI libraries of Qt. They are best for me. One much more thing: you develop applications with C++ in Qt. ( Qt is cute not quti )

You can develop Qt applications for different hardware architectures. For raspberry pi we create a virtual machine ( host ) and we compile our projecst crossly. I just try to say we must make a cross compilation. As it is obvious our host hardware is (most probably) intel but the raspberry pi is ARM. They are totally different. Like white and black or Brad and Angelina. So to make understandable (?) what we do in intel, we cross compile our code then it will be ok for Rasp. To do that we need some toolchains that we will install in our virtual machine.

First thing first, lets create a virtual machine with virtual box. You can download virtual box from here https://www.virtualbox.org/wiki/Downloads

Then follow instruction in the video. Give about 30 GB space , it is enough. Then open it. Before go raspberry pi, be sure that , you supply the raspberry pi 5V 2.1A power source or much current. If you suppy it from your computer or you phone charger , then you will waste your hours in the next. If rasp is connected to the HDMI and you see the yellow lightning figure for a long time then you will have a power problem. If you have a problems with power do not go further ! Power be with you ! )

Now go to raspberry pi. Make it ssh available, ( create a directory which name is ssh in the boot directory with cmd.exe) log in with ssh. With putty ( you can use different serial terminal/emulator ) log in, User name is pi, passwd raspberry. Now change the root passwd and enable to login as a root.

 


sudo nano /etc/ssh/sshd_config

find the line PermitRootLogin and make it comment out.

then say yes

PermitRootLogin yes

to out ctrl -x and push the y

then give root password.

sudo passwd root
(mine is 1234)
sudo reboot

sudo nano /etc/ssh/sshd_config

find the line PermitRootLogin and make it comment out.

then say yes

PermitRootLogin yes

to out ctrl -x and push the y

then give root password.

sudo passwd root
(mine is 1234)
sudo reboot

 

login as a root. User name is “root” and paswwd is “what you give” 

Then, 

nano /etc/apt/sources.list 
uncomment the last line.

 

apt-get update
apt-get dist-upgrade
reboot
rpi-update
reboot
-be sure rpi update work, try rpi-update again
*** Your firmware is already up to date – OKAY
sudo apt-get build-dep qt5-qmake
sudo apt-get build-dep libqt5webengine-data
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
mkdir /usr/local/qt5pi
chown -R root:root /usr/local/qt5pi

apt-get update
apt-get dist-upgrade
reboot
rpi-update
reboot
-be sure rpi update work, try rpi-update again
*** Your firmware is already up to date – OKAY
sudo apt-get build-dep qt5-qmake
sudo apt-get build-dep libqt5webengine-data
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
mkdir /usr/local/qt5pi
chown -R root:root /usr/local/qt5pi

That is ok for Raspberr pi. Do not power off it. We have a long night... 


In ubuntu : 
We create the vm open it, ( for network connect it via ethernet cable. I did it like that I did not have to make any additional configuration, I did not use Wifi. Create a good network with cables between your raspberry pi and computer. ) 

 

 

sudo passwd root
su
apt-get update

apt-get -y upgrade

apt-get install gcc git bison python gperf pkg-config

sudo mkdir /opt/qt5pi

sudo chown 1000:1000 /opt/qt5pi

cd /opt/qt5pi

git clone https://github.com/raspberrypi/tools

nano ~/.bashrc - it keep to long

export PATH=$PATH:/opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

reboot

wget http://download.qt.io/official_releases/qt/5.12/5.12.4/single/qt-everywhere-src-5.12.4.tar.xz

tar xf qt-everywhere-src-5.12.4.tar.xz
cp -R qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabihf-g++

sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf

mkdir sysroot sysroot/usr sysroot/opt

rsync -avz root@192.168.16.25:/lib sysroot

rsync -avz root@192.168.16.25:/usr/include sysroot/usr

rsync -avz root@192.168.16.25:/usr/lib sysroot/usr

rsync -avz root@192.168.16.25:/opt/vc sysroot/opt

mv sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup

ln -s sysroot/opt/vc/lib/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0

mv sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0_backup

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

wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py

chmod +x sysroot-relativelinks.py

./sysroot-relativelinks.py sysroot

check syncronized file again

rsync -avz root@192.168.16.25:/lib sysroot

rsync -avz root@192.168.16.25:/usr/include sysroot/usr

rsync -avz root@192.168.16.25:/usr/lib sysroot/usr

rsync -avz root@192.168.16.25:/opt/vc sysroot/opt

./sysroot-relativelinks.py sysroot

mkdir qt5build

cd qt5build

../qt-everywhere-src-5.12.4/configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtscript -nomake examples -make libs -pkg-config -no-use-gold-linker -v


=> for raspberry pi 0 => -device linux-rasp-pi-g++

=> for raspberry pi 2 => -device linux-rasp-pi2-g++

=> for raspberry pi 3 => -device linux-rasp-pi3-g++

=> for raspberry pi 3 + vc4 driver => -device linux-rasp-pi3-vc4-g++

make -j4

make install

cd /opt/qt5pi

rsync -avz sysroot/usr/local/qt5pi root@192.168.16.25:/usr/local



sudo passwd root
su
apt-get update

apt-get -y upgrade

apt-get install gcc git bison python gperf pkg-config

sudo mkdir /opt/qt5pi

sudo chown 1000:1000 /opt/qt5pi

cd /opt/qt5pi

git clone https://github.com/raspberrypi/tools

nano ~/.bashrc - it keep to long

export PATH=$PATH:/opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

reboot

wget http://download.qt.io/official_releases/qt/5.12/5.12.4/single/qt-everywhere-src-5.12.4.tar.xz

tar xf qt-everywhere-src-5.12.4.tar.xz
cp -R qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabihf-g++

sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.12.4/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf

mkdir sysroot sysroot/usr sysroot/opt

rsync -avz root@192.168.16.25:/lib sysroot

rsync -avz root@192.168.16.25:/usr/include sysroot/usr

rsync -avz root@192.168.16.25:/usr/lib sysroot/usr

rsync -avz root@192.168.16.25:/opt/vc sysroot/opt

mv sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup

ln -s sysroot/opt/vc/lib/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0

mv sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0_backup

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

wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py

chmod +x sysroot-relativelinks.py

./sysroot-relativelinks.py sysroot

check syncronized file again

rsync -avz root@192.168.16.25:/lib sysroot

rsync -avz root@192.168.16.25:/usr/include sysroot/usr

rsync -avz root@192.168.16.25:/usr/lib sysroot/usr

rsync -avz root@192.168.16.25:/opt/vc sysroot/opt

./sysroot-relativelinks.py sysroot

mkdir qt5build

cd qt5build

../qt-everywhere-src-5.12.4/configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtscript -nomake examples -make libs -pkg-config -no-use-gold-linker -v


=> for raspberry pi 0 => -device linux-rasp-pi-g++

=> for raspberry pi 2 => -device linux-rasp-pi2-g++

=> for raspberry pi 3 => -device linux-rasp-pi3-g++

=> for raspberry pi 3 + vc4 driver => -device linux-rasp-pi3-vc4-g++

make -j4

make install

cd /opt/qt5pi

rsync -avz sysroot/usr/local/qt5pi root@192.168.16.25:/usr/local

 

-- 

install qt-creator

apt-get install qtcreator

Lets create simple Hello world console application. With qt-creator choose new console application.

 

test and debug may meet error below:

QML debugging is enabled. Only use this in a safe environment.
qt.qpa.egldeviceintegration: Failed to load EGL device integration "eglfs_brcm"
* failed to add service - already in use?
Application finished with exit code 1.

 

Remote debug/Test, you could use vnc for test:

arguments:

-platform vnc:size=800x480,port=12345,depth=32,mmsize=600x350

 

 

downlowd vnc viewer:

https://www.realvnc.com/en/connect/download/viewer/

connect:

ip:12345

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值