Skip to content

Instantly share code, notes, and snippets.

@carloswherbet
Forked from Jokymon/crossbuild_qt5_for_rpi.sh
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carloswherbet/842b71d0cec8ff78a3fb to your computer and use it in GitHub Desktop.
Save carloswherbet/842b71d0cec8ff78a3fb to your computer and use it in GitHub Desktop.
Protocol from Cross compiling Qt5 for Raspberry Pi
set -e
PREFIX=~/opt/qt5pi
ROOTFS_MOUNT=/mnt/rasp-pi-rootfs
# On Ubuntu 14.04 do the following first to get the ia32-lib
if [ `lsb_release -ds` -eq "Ubuntu 14.04 LTS" ]
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
fi
### Get the RaspberryPi cross compilation tools
git clone https://github.com/raspberrypi/tools.git
mv tools rpi-tools
### Create the environment for building our cross compiled Qt
mkdir qt-on-raspberry
cd qt-on-raspberry
### Get the root file system and mount it
# Get the latest Raspbian image
wget http://downloads.raspberrypi.org/raspbian_latest
mv raspbian_latest raspbian_latest.zip
unzip raspbian_latest.zip
sudo mkdir $ROOTFS_MOUNT
# The offset is probably always the same due to the requirements for RaspberryPi SD Cards
sudo mount -o loop,offset=62914560 2014-09-09-wheezy-raspbian.img $ROOTFS_MOUNT
### Get the Qt sources and cross compilation scripts
git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
git clone git://gitorious.org/qt/qt5.git
cd qt5
./init-repository
cd ..
### Fix symlinks and lib paths in the mounted rootfs
cd cross-compile-tools
sudo ./fixQualifiedLibraryPaths $ROOTFS_MOUNT ~/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
cd ..
### Compiling qtbase
cd qt5/qtbase
./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot $(ROOTFS_MOUNT) -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix $(PREFIX)
make -j4
sudo make install
cd ..
### Compile other packages
for MODULE in qtimageformats qtsvg qtscript qtxmlpatterns qtdeclarative qtsensors qtgraphicaleffects qtlocation qtserialport qttools qtquick1 qtquickcontrols
do
cd $MODULE
$PREFIX/bin/qmake .
make -j4
sudo make install
cd ..
done
### Finish the modified Raspbian image
cd ..
sync
sudo umount $ROOTFS_MOUNT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment