Skip to content

Instantly share code, notes, and snippets.

@Brainiarc7
Created March 2, 2017 17:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Brainiarc7/5b099a9e0be7a5400b74aaf3a2a34ab4 to your computer and use it in GitHub Desktop.
Save Brainiarc7/5b099a9e0be7a5400b74aaf3a2a34ab4 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
@jackhistoria
Copy link

git clone https://git.gitorious.org/qt/qt5.git qt5 --depth=1 is down and on https://github.com/Distrotech/qt-5.git as an option.
(git clone git clone https://github.com/Distrotech/qt-5.git qt5 --depth=1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment