- Back to Home »
- QT Framework , Raspberry PI »
- Build QT for Raspberry PI
Sunday, October 15, 2017
Bài viết này sẽ hướng dẫn cách build QT để viết chương trình có GUI trên Raspberry PI
- qt-everywhere-opensource-src-5.3.2
- 2017-07-05-raspbian-jessie-lite (bản lite không có đồ họa)
1. Build QT
#build QT => cd to qtbase folder
RPI_TOOLCHAIN=/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
RPI_SYSROOT=/home/linuxpc/2017-07-05-raspbian-jessie-lite-rootfs
#configure
./configure -opengl es2 -device linux-rasp-pi-g++ \
-device-option CROSS_COMPILE=$RPI_TOOLCHAIN \
-opensource -confirm-license -optimized-qmake \
-reduce-exports -release -make libs -skip qtwebkit \
-sysroot $RPI_SYSROOT \
-prefix /usr/local/qt5pi
#affter install you have 2 folder: one is /usr/local/qt5pi (qmake for host)
#and one is $RPI_SYSROOT/usr/local/qt5pi (lib for rpi)
make -j4
make install
Sau khi xong make install thì sẽ thu được 2 thư mục của QT
- /usr/local/qt5pi : dùng để build app cho RPI
- $RPI_SYSROOT/usr/local/qt5pi : bạn copy thư mục này xuống SD card
2. Build app
#build app
export PATH=$PATH:/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
export QMAKESPEC=/usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g++
cd /path/to/myproject
/usr/local/qt5pi/bin/qmake
make