Skip to content

Instantly share code, notes, and snippets.

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 jd-boyd/0ffd7b6a17e92c58ad2ebfaa83b95cbe to your computer and use it in GitHub Desktop.
Save jd-boyd/0ffd7b6a17e92c58ad2ebfaa83b95cbe to your computer and use it in GitHub Desktop.
Setting up a Raspberry Pi QT5 cross compile environment on Linux

Generating an environment on Linux to cross-compile QT applications for a Raspberry Pi running Debian Wheezy:

Grab tools (for the cross-compiler tool chain) and firmware (for the OpenGL libraries) from the Raspberry Pi GitHub repository:

git clone https://github.com/raspberrypi/tools.git --depth=1
git clone https://github.com/raspberrypi/firmware.git --depth=1

Copy OpenGL stuff to the toolchain's sysroot:

cp -a firmware/opt  tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root

Workaround for some EGL include files being in the wrong directory:

cp  tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root/opt/vc/include/interface/vcos/pthreads/* tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root/opt/vc/include/interface/vcos

Grab Qt:

git clone https://git.gitorious.org/qt/qt5.git qt5 --depth=1
cd qt5
./init-repository --no-webkit

Configure and compile:

./configure -prefix /opt/qt50-snapshot -hostprefix $PWD/../qmake_for_pi  \
-release -device linux-rasp-pi-g++ -device-option \
CROSS_COMPILE=$PWD/../tools/arm-bcm2708/linux-x86/bin/arm-bcm2708-linux-gnueabi- 
-sysroot  \
$PWD/../tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root \
-device-option DISTRO=wheezy -opensource -confirm-license -nomake  \
examples -nomake tests -optimized-qmake -reduce-relocations -reduce-exports

Build the binaries:

./build -j$(nproc)

Copy mkspecs folder to the sysroot. Qt Creator 2.5 expects them to be there, and will throw a "The default mkspec symlink is broken" error otherwise:

cd ..
cp -a qmake_for_pi/mkspecs  tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root/opt/qt50-snapshot

To cross-compile applications: in Qt Creator 2.5, go to menu "tools" -> "options" -> "Build & Run"

Tab "toolchains" add:

/YOURFOLDER/tools/arm-bcm2708/linux-x86/bin/arm-bcm2708-linux-gnueabi-gcc
Tab "Qt versions" add: /YOURFOLDER/qmake_for_pi/bin/qmake

Under "Linux "devices" add the SSH login details of your Pi and specify the remote folder on the Pi your application should be uploaded to in your projects' .pro file, like this:

target.path = /tmp
INSTALLS += target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment