sdt / docker-raspberry-pi-cross-compiler

Raspberry Pi cross-compiler and sysroot in a Docker container.
https://hub.docker.com/r/sdthirlwall/raspberry-pi-cross-compiler/
MIT License
246 stars 69 forks source link

Compile Qt (5.6) #18

Closed antis81 closed 7 years ago

antis81 commented 8 years ago

I'm writing a script to cross-compile Qt with rpxc and got a bit stuck on the "configure" step of Qt5 cross compile. It expects an attribute pointing to the cross-compile toolchain. Complete call looks like this:

#!/bin/sh
WD='/path/to/workdir'
TARGET_SYSROOT='/path/to/target/sysroot'
CC="'rpxc rpxc-'"

./configure \
 -v -release -opengl es2 -device linux-rasp-pi2-g++ \
 -device-option CROSS_COMPILE=${CC} \
 -opensource -confirm-license -make libs \
 -sysroot ${TARGET_SYSROOT} -prefix /usr/local/qt5pi -extprefix ${WD}/qt5pi -hostprefix ${WD}/qt5 \
 -no-linuxfb -no-xcb -no-qml-debug -no-cups -no-pulseaudio -no-alsa -no-evdev \
 -qt-libjpeg -qt-libpng

The compiler is suffixed by the configure script (e.g. with "gcc"). Any idea how to get this right?

sdt commented 8 years ago

I'll take a proper look at this tonight, but typically the trick is to run the configure script inside rpxc, rather than have configure call rpxc-wrapped tools.

I'd try removing the -device-option CROSS_COMPILE=${CC} line and then running it as rpxc ./your-configure-script.

There's a bunch of environment variables pre-set in rpxc which can be handy: --host $HOST comes up quite a bit.

antis81 commented 8 years ago

Thanks for the quick reply! Yeah, I needed some time to understand how stuff works. :smile: Anyway, rpxc env (same with rpxc -- env) outputs the correct environment vars, but up to now I couldn't manage to hand the environment over to the configure script. I already tried with -device-option CROSS_COMPILE=$CROSS_COMPILE without luck. I'll follow your advice and try it without that option.

sdt commented 8 years ago

I've built a docker image against my not-yet-released onbuild branch. This branch has a sort-of-hacky install-raspbian script which installs raspbian dev packages into the embedded sysroot.

Give this a try, it should get you at least part-way there.

Create a Dockerfile with:

FROM sdt4docker/raspberry-pi-cross-compiler:qt-testing
# Install native debian build tools
RUN install-debian build-essential
# Install raspberry pi dev packages
RUN install-raspbian libgles2-mesa-dev zlib1g zlib1g-dev

(Don't put it in the same tree as the qt sources. The docker context will be huge.)

Then create yourself a custom downstream image to build with:

export RPXC_IMAGE=rpxc-qt
docker build -t $RPXC_IMAGE .

With the RPXC_IMAGE environment variable set to your custom image, rpxc will automatically use that.

Then you should be able to start building with:

# Make sure these are single quotes, not double quotes.
# You want the $VARS to be expanded inside the container, not in your shell.
rpxc bash -c './configure -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=$CROSS_COMPILE [other options]'

All the other non-cross-compile options will work. Your $WD should probably become /build as that's where your $PWD gets mounted in the running container. I don't think you need -sysroot, but if you do, set it to $RASPBIAN_ROOT.

There's still a bunch of raspbian packages you'll need to add. The basic flow is to build, see where it bombs out, add that package with install-raspbian, build a new docker image and try again.

In that scenario its quicker to keep adding entire new RUN install-raspbian $package lines.

With any luck, you'll eventually get all the dependencies and it will build successfully.

sdt commented 7 years ago

Closing as part of an old issue tidy-up. Please create a new issue if necessary.