Skip to content

Instantly share code, notes, and snippets.

@alepez
Created November 2, 2017 23:13
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 alepez/fd8ddfa779a3e10b1be55e2bc6347421 to your computer and use it in GitHub Desktop.
Save alepez/fd8ddfa779a3e10b1be55e2bc6347421 to your computer and use it in GitHub Desktop.
Cross Compile Qt 5.9.2 for Raspberry Pi 3 on Gentoo

Example of make.conf with distcc enabled

/etc/portage/make.conf

CFLAGS="-mcpu=cortex-a53 -mfloat-abi=hard -mfpu=neon-fp-armv8 -O2 -pipe"
CXXFLAGS="${CFLAGS}"

CHOST="armv7a-hardfloat-linux-gnueabi"

# portage is readonly on squashfs to save space and inodes
DISTDIR=/var/lib/portage/distfiles

LC_MESSAGES=C

# The use of -lM in the MAKEOPTS variable will prevent spawning too many tasks
# when some of the distcc cluster hosts are unavailable (increasing the amount
# of simultaneous jobs on the other systems) or when an ebuild is configured to
# disallow remote builds (such as with gcc). This is accomplished by refusing
# to start additional jobs when the system load is at or above the value of M.
# 4 local cores, 4+8 remote cores
# j=2*(remote+local)+1
# l=local
MAKEOPTS="-j33 -l4"
EMERGE_DEFAULT_OPTS="--jobs=5 --load-average=4"

USE="${USE} cacert zsh-completion"
USE="${USE} -doc -nls -X -gtk"
USE="${USE} gles gles2 egl -xcb eglfs gallium llvm"

FEATURES="${FEATURES} distcc distcc-pump"
VIDEO_CARDS="vc4"

/var/lib/portage/world

media-libs/raspberrypi-userland
sys-devel/distcc

Create sysroot, e.g. in /opt/rpi/sysroot

mkdir /opt/rpi/sysroot && cd /opt/rpi/sysroot
ssh pi "cd / && tar cpf - lib usr/include  usr/lib usr/local/include usr/local/lib" | tar xpvf -

Download rpi toolchain in /opt/rpi3/tools/arm-bcm2708/

Download Qt sources, e.g. in /opt/Qt/5.9.2/Src

I usually make a copy of sources before compiling, e.g. /opt/Qt/5.9.2/Src_linux-rasp-pi3-g++

cd /opt/Qt/5.9.2/Src_linux-rasp-pi3-g++
./configure -release -opengl es2 -device linux-rasp-pi3-g++ \
  -device-option CROSS_COMPILE=/opt/rpi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- \
  -sysroot /opt/rpi3/gentoo-sysroot/ \
  -extprefix /opt/Qt/5.9.2/linux-rasp-pi3-g++ \
  -v -nomake examples -nomake tests -no-use-gold-linker \
  -opensource -confirm-license -skip qtscript
gmake -j7
gmake install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment