Qt World Summit: Register Today!

Cross compile from Ubuntu Desktop to Raspberry Pi 2

  • Hey there!

    I'm using:
    PC: Ubuntu Desktop 16.04 (64-bit) with Qt Creator 5.8
    Raspberry Pi 2: Raspbian Jessie Lite
    My main goal - develop simple Qt application on my desktop PC and compile it for Raspberry Pi 2 which has 7" LCD connected.

    I used this tutorial https://wiki.qt.io/RaspberryPi2EGLFS but instead of 5.6 I used 5.8 branch, so basically step 7 was "git clone git://code.qt.io/qt/qtbase.git -b 5.8" and in the end no errors appeared.
    I then used this tutorial https://www.ics.com/blog/configuring-qt-creator-raspberry-pi starting from step 6 to create some test application. This application is compiling without any errors on my Ubuntu Desktop, but when I choose to build it for Raspberry Pi, I get this error on make action:
    /home/janisk/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.52: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'

    I found this topic https://forum.qt.io/topic/64086/libqt5core-so-undefined-reference-to-__cxa_throw_bad_array_new_length-cxxabi_1-3-8/6 with similar error, but I already have that -spec devices suggested in Build settings for Raspberry Pi: qmake /home/janisk/Qt/testing/widgettest/widgettest.pro -spec devices/linux-rasp-pi2-g++ && /usr/bin/make qmake_all

    First question: do I need to point to 64-bit compiler and debugger on my Build&Run Raspberry Pi Kit? Or should it be 32-bit since Raspberry Pi is 32-bit?
    Second question: what does that error mean in the first place?

  • Lifetime Qt Champion

    @JanisK It doesn't matter whether the compiler itself is 32bit or 64bit, it just needs to generate 32bit ARM binaries.
    Regarding the error: looks like some library is missing.

    ldd /home/janisk/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.52

  • @jsulm - thanks for the reply.

    I tried to run ldd /home/janisk/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.52 and got this:
    not a dynamic executable

    But I tried with version 5.7 instead of 5.8 (git clone git://code.qt.io/qt/qtbase.git -b 5.7) and then the rest commands from tutorial, and everything works in 5.7 with no problems.

  • I have the same problem too.

    Qt Creator compile any example:
    libicui18n.so.52: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'

    Raspberry Pi2,2017-01-11-raspbian-jessie.zip,Qt 5.8.0

    I don know how to solve it.

  • Lifetime Qt Champion

    @peterlin82 Check the dependencies for libicui18n.so.52 using ldd, looks like a library is missing.

  • In Raspberry Pi 2
    ldd /usr/lib/arm-linux-gnueabihf/libicui18n.so.52

    linux-vdso.so.1 (0x7ee13000)
    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76dc6000)
    libicuuc.so.52 => /usr/lib/arm-linux-gnueabihf/libicuuc.so.52 (0x76c66000)
    libicudata.so.52 => /usr/lib/arm-linux-gnueabihf/libicudata.so.52 (0x755e9000)
    libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x755d6000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x754fa000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x7547f000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x75451000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x75310000)
    /lib/ld-linux-armhf.so.3 (0x54b69000)

  • Hey!

    I have the same error when i try to compile qt 5.8 for raspberry pi 3.

    i get the same results as @peterlin82 and @JanisK when trying the ldd /usr/lib/arm-linux-gnueabihf/libicui18n.so.52 on RPI 3 and on Ubuntu.

    I'm not sure what to tell of it, don't get any obvious errors what i can see.

  • Lifetime Qt Champion

  • @jsulm I can't really find anything usefull for me, but i might be missing something...

  • I also got the same error when cross compile Qt samples for Raspberry Pi 3 on Ubuntu 16.04 (64-bit). I'm using Qt Creator 5.8.

    I got this error on both Raspbian 1.1 and Ubuntu Mate 16.04.2.

  • I managed to cross compile Qt 5.8 for the Raspberry Pi 3 (latest Raspbian) with the xbomber tip from this post (at the end): https://github.com/raspberrypi/tools/issues/50
    Was following the EGLFS guide ( https://wiki.qt.io/RaspberryPi2EGLFS ) on a Linux Mint 17.3 x64 virtual machine.
    I used the linux-rasp-pi2-g++ device configuration and the arm-rpi-4.9.3-linux-gnueabihf toolchain.
    Used the Qt 5.8 source tar.gz without the qtserialbus and qtwebengine

  • @hubaiz Looking promising!
    I just wonder, the second script, is there anything else i need to change than the path to tools and sysroot when targeting qt5.8 and raspberry 3?

    i changed the paths and ran the script in qtbase but got errors.

    Running configuration tests...
    Checking for valid makespec... 
    + cd /home/christian/raspi/qtbase/config.tests/common/verifyspec && /home/christian/raspi/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "QMAKE_CFLAGS += --sysroot=/home/christian/raspi/sysroot" "QMAKE_CXXFLAGS += --sysroot=/home/christian/raspi/sysroot" "QMAKE_LFLAGS += --sysroot=/home/christian/raspi/sysroot" -early "CONFIG += cross_compile" /home/christian/raspi/qtbase/config.tests/common/verifyspec
    + cd /home/christian/raspi/qtbase/config.tests/common/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make
    > rm -f verifyspec.o
    > rm -f *~ core *.core
    > /home/christian/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -c -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/home/christian/raspi/sysroot --sysroot=/home/christian/raspi/sysroot -O2 -std=gnu++11 -Wall -W -fPIC  -I. -I/home/christian/raspi/qtbase/mkspecs/devices/linux-rasp-pi-g++ -o verifyspec.o verifyspec.cpp
    > cp: cannot stat 'home/christian/raspi/sysroot/usr/lib/arm-linux-gnueabihf/crt*': No such file or directory
    > /home/christian/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/home/christian/raspi/sysroot/opt/vc/lib -Wl,-rpath-link,/home/christian/raspi/sysroot/usr/lib/ -Wl,-rpath-link,/home/christian/raspi/sysroot/lib/ -mfloat-abi=hard --sysroot=/home/christian/raspi/sysroot --sysroot=/home/christian/raspi/sysroot -Wl,-O1 -o verifyspec verifyspec.o    
    > cp: cannot stat 'home/christian/raspi/sysroot/usr/lib/arm-linux-gnueabihf/crt*': No such file or directory
    > /home/christian/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
    > /home/christian/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
    > /home/christian/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
    > collect2: error: ld returned 1 exit status
    > Makefile:65: recipe for target 'verifyspec' failed
    > make: *** [verifyspec] Error 1
    Note: Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx
    ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.

    Got any idea whats wrong?

  • @Fifkie Have you fix this error?

  • I ran into this a few weeks ago when upgrading from Qt 5.7 to 5.8 and following the wiki's instructions. I added -skip qtwebengine -no-icu when I ran ./configure because I don't need those features in my app and it worked fine after that.

  • @StoatPatronus Did you put it in the script? I get an error when i try to run it:

    ERROR: Unknown command line option '-skip'.

    Have tried to put in the beginning and in the end of the script, but i guess as long it doesn't know what it is that does not matter.

  • Lifetime Qt Champion

    @Fifkie Can you show your script?

  • @jsulm Sure!

    It's this script:

    ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/home/marco/Qt/5.3/tools-master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /home/marco/Qt/5.3/sysroot -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix /usr/local/qt5pi -v

    With the "-skip qtwebengine -no-icu" added. I've tried right in the beginning after ./configure, in the end and after "-opensource". Neither worked.

  • @Fifkie

    I was having the same issue and reconfigured with just the -no-icu flag and everything worked fine (I use qtwebengine in my app) my config string is as follows...

    ./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -no-icu -hostprefix ~/raspi/qt5 -v

  • @Fifkie Here's my command line, please replace the {{ stuff in brackets }} with the paths for your system:

    ./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE={{pi_folder}}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot {{pi_folder}}/sysroot -opensource -confirm-license -skip qtwebengine -no-icu -make libs -prefix /usr/local/qt5pi -extprefix {{pi_folder}}/qt5pi -hostprefix {{pi_folder}}/qt5

    One thing I noticed in the config string you posted is it looks like Qt 5.3 (/home/marco/Qt/5.3/...etc) which I haven't tried - I only tried with 5.8.

  • @StoatPatronus Now as i review the script i posted, i must have just copied that from the tut, not from the script i use because there are several things not matching. But I got Kukkimonsuta's tutorial working for me so i got it working now. For anyone else looking for a solution just follow the steps at https://github.com/Kukkimonsuta/rpi-buildqt . Only thing i had to change was with one of the scripts i got an error that it didn't have the permission to sync one folder from the RPI. So in the sync script i just added

    --exclude 'vnc'

    in the rsync under "== Copy /usr/lib =="
    That's because it wouldn't sync the vnc-folder.

  • @Fifkie I'm glad you got it working. Kukkimonsuta's guide is very helpful. For my project I wrote a couple Ansible playbooks to automate the process, so it's easy to upgrade to new versions of Qt in the future. Unfortunately I can't share them at this point, but I may later if I clean them up.

  • Banned

    This post is deleted!

  • I cleaned up my ansible playbooks and posted them at https://bitbucket.org/johnwoltman/build_qt_for_pi_with_ansible

Log in to reply