Cross-Compilation Qt Ubuntu/RaspberryPI3 problem with libicu
-
Good evening everyone,
I'm struggling with the cross-compilation of the Qt library for RaspberryPi 3. In particular, I stumbled upon a problem concerning the icu library. The make process interrupts with the following error:
/home/quantum/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/quantum/RaspberryPi3/sysroot -Wl,--gc-sections -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath,/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/qt-5.9/sources/qtbase/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialport/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/opt/vc/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/lib/arm-linux-gnueabihf -o ../../../bin/canbusutil .obj/main.o .obj/readtask.o .obj/canbusutil.o .obj/sigtermhandler.o .obj/moc_readtask.o .obj/moc_canbusutil.o .obj/moc_sigtermhandler.o -L/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib -L/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialbus/lib -lQt5SerialBus -L/home/quantum/RaspberryPi3/qt-5.9/sources/qtbase/lib -lQt5Core -lpthread
/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.57: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit status
Makefile:92: recipe for target '../../../bin/canbusutil' failed
make[4]: *** [../../../bin/canbusutil] Error 1
make[4]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialbus/src/tools/canbusutil'
Makefile:44: recipe for target 'sub-canbusutil-make_first' failed
make[3]: *** [sub-canbusutil-make_first] Error 2
make[3]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialbus/src/tools'
Makefile:97: recipe for target 'sub-tools-make_first' failed
make[2]: *** [sub-tools-make_first] Error 2
make[2]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialbus/src'
Makefile:46: recipe for target 'sub-src-make_first' failed
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources/qtserialbus'
Makefile:230: recipe for target 'module-qtserialbus-make_first' failed
make: *** [module-qtserialbus-make_first] Error 2I have googled the problem and found out that is a problem of gcc version with which the libicu has been compiled. So I downloaded the source code, compiled in the host machine, then cross-compiled them successfully for raspberry pi 3, but I haven't been able to link them to the qt building during configuration. I tried many options:
./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/RaspberryPi3/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/RaspberryPi3/qt-5.9/build-eglfs/qt5 -hostprefix ~/RaspberryPi3/qt5.9/build-eglfs/qt5-host -v -no-use-gold-linker -skip qtwayland -skip qtscript -icu -I "/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/include" -L "/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib" -R "/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib"
and
./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/RaspberryPi3/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/RaspberryPi3/qt-5.9/build-eglfs/qt5 -hostprefix ~/RaspberryPi3/qt5.9/build-eglfs/qt5-host -v -no-use-gold-linker -skip qtwayland -skip qtscript -icu ICU_INCDIR="/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/include" ICU_LIBDIR="/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib" ICU_PREFIX="/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build"
but nothing successful so far.
I'm working on Ubuntu 16.04.3 LTS 64bit, cross compiling QT 5.9.1 for RaspberryPi3 on 2017-11-29-raspbian-stretch, using the official toolchain from https://github.com/raspberrypi/tools. I downloaded the QT source as an archive and not from the repo.
Thanks in advance for your help.
-
Did you clean your build directory after you compiled ICU and tried to use it? Qt's configure gets very confused when you change libs from one build to another like that.
Also what is the output from the build with the first configure line? That one looks correct and should pick up the custom built icu libs.
Edit:
If it helps here is a configure line from my mac using a custom icu. I linked the icu libs explicitly on the configure line to get it to work. You can try that. :)./configure -opensource -qt-sql-sqlite -release -platform macx-g++ -confirm-license -nomake examples -nomake tests -icu -L/usr/local/lib -I/usr/local/include -licuuc -licui18n
My custom built icu was installed in /usr/local.
-
Thank you for your answer. I tried the options like you suggested, the -l option can't be taken however, it doesn't recognize it. The problem is that in config.cache, under ICU, using the options -L and -I doesn't pick the paths, while using the keys ICU_LIBDIR and ICU_INCDIR the paths are in config.cache as well:
cache.icu.KEYS = result source sources.2.libs sources.2.includedir sources.2.cflags sources.2.version sources.2.export
cache.icu.result = true
cache.icu.source = 2
cache.icu.sources.2.libs = "-L/home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib -licui18n -licuuc -licudata"
cache.icu.sources.2.includedir = /home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/include/unicode
cache.icu.sources.2.cflags =
cache.icu.sources.2.version =
cache.icu.sources.2.export =Using the first line of configure, with -L and -I options I have something like the following:
cache.icu.KEYS = result source sources.2.libs sources.2.includedir sources.2.cflags sources.2.version sources.2.export
cache.icu.result = true
cache.icu.source = 2
cache.icu.sources.2.libs = "-licui18n -licuuc -licudata"
cache.icu.sources.2.includedir =
cache.icu.sources.2.cflags =
cache.icu.sources.2.version =
cache.icu.sources.2.export =I tried to add icu path library to pkg_config_path in the host system (lib and include), but I'm not sure about the include path, since include contains two subfolders and the header files are there. Should I pick one of them so the path will bring directly to the headers or qt knows the include folder is subdivided into two subfolders where the headers are?
-
Ok so it looks like it was definitely picking up your -L correctly. However it is not able to use it.
This to me suggests maybe the icu libs you built are not compatible with the Qt you are building. What happens in this instance is gcc just ignores them as if they weren't there. It leads you to believe that it couldn't find the lib when in fact it did, it just wasn't usable.
So to explore down this line:
-
What does
ls -lh /home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib
show? -
What is the output of
file /home/quantum/RaspberryPi3/libicu/build_icu_rpi/icu_build/lib/libicui18n.so.XX.X
, replace XX.X with your versions. Should look something like:
[shockwave] /lib > file libicui18n.so.60.2 libicui18n.so.60.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=eab39b35aabb72d7746b5984bcbcc8a40b63155c, stripped
-
-
The output of file is:
libicui18n.so.57.1: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=5168bcc00d5630ea6fc53a5ee429efb12bf791fb, not stripped
and it seems correct, since I'm trying to cross-compile for raspberry so I'm linking the icu building cross-compiled for arm.ls -lh gives me:
ls -lh
total 30M
drwxrwxr-x 3 quantum quantum 4,0K gen 17 17:43 icu
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicudata.so -> libicudata.so.57.1
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicudata.so.57 -> libicudata.so.57.1
-rwxr-xr-x 1 quantum quantum 25M gen 17 17:43 libicudata.so.57.1
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicui18n.so -> libicui18n.so.57.1
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicui18n.so.57 -> libicui18n.so.57.1
-rwxr-xr-x 1 quantum quantum 2,7M gen 17 17:43 libicui18n.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicuio.so -> libicuio.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicuio.so.57 -> libicuio.so.57.1
-rwxr-xr-x 1 quantum quantum 51K gen 17 17:43 libicuio.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicule.so -> libicule.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicule.so.57 -> libicule.so.57.1
-rwxr-xr-x 1 quantum quantum 374K gen 17 17:43 libicule.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libiculx.so -> libiculx.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libiculx.so.57 -> libiculx.so.57.1
-rwxr-xr-x 1 quantum quantum 47K gen 17 17:43 libiculx.so.57.1
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicutest.so -> libicutest.so.57.1
lrwxrwxrwx 1 quantum quantum 18 gen 17 17:43 libicutest.so.57 -> libicutest.so.57.1
-rwxr-xr-x 1 quantum quantum 85K gen 17 17:43 libicutest.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicutu.so -> libicutu.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicutu.so.57 -> libicutu.so.57.1
-rwxr-xr-x 1 quantum quantum 197K gen 17 17:43 libicutu.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicuuc.so -> libicuuc.so.57.1
lrwxrwxrwx 1 quantum quantum 16 gen 17 17:43 libicuuc.so.57 -> libicuuc.so.57.1
-rwxr-xr-x 1 quantum quantum 1,7M gen 17 17:43 libicuuc.so.57.1
drwxrwxr-x 2 quantum quantum 4,0K gen 17 17:43 pkgconfigand all the files can be executed.
I'll try to build the icu version 60.2 and see if it is accepted.
-
@Fab001 said in Cross-Compilation Qt Ubuntu/RaspberryPI3 problem with libicu:
/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.57: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit statusOk so the above shows it's definitely not using your custom libs. Here's another few things to try:
-
Hide the above ICU, I usually just do this by
chmod 000 /home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf/libicu*
Then you can restore later withchmod 755 libicu*
. This will hide it from the build system. Then if it still doesn't pick up your custom libs then you definitely have a build issue between Qt and ICU. If it does pick it up then there is just a library path order issue. -
Check the actual Makefile that qmake generates for the project that has the ICU error. You can post it here and I'll analyze it or you can just check it yourself to see if your -L and -l are included properly.
-
This is not something I would recommend, but you could always replace the libicu* files in sysroot with your custom ones. That is a really bad idea that is bound to lead to problems later, but it would work if the libs are good. It's honestly better to figure out the real problem though. This should be a last ditch effort for a deadline on a project and not something you should do casually.
-
-
I tried your first advice, that is hide the libicu taken from the Raspberry, and actually it says at configure time that doesn't find any icu, so the custom ones are not taken into consideration at all.
Everytime I try to compile with custom icu the log file islooking for library icu
Trying source 0 (type inline) of library icu ...
=> source failed condition 'config.win32 && !features.shared'.
Trying source 1 (type inline) of library icu ...
=> source failed condition 'config.win32 && features.shared'.
Trying source 2 (type inline) of library icu ...- cd /home/quantum/RaspberryPi3/qt-5.9/sources2/config.tests/unix/icu && PKG_CONFIG_SYSROOT_DIR=/home/quantum/RaspberryPi3/sysroot PKG_CONFIG_LIBDIR=/home/quantum/RaspberryPi3/sysroot/usr/lib/pkgconfig:/home/quantum/RaspberryPi3/sysroot/usr/share/pkgconfig:/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf/pkgconfig /home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console single_arch" "QMAKE_CFLAGS += --sysroot=/home/quantum/RaspberryPi3/sysroot" "QMAKE_CXXFLAGS += --sysroot=/home/quantum/RaspberryPi3/sysroot" "QMAKE_LFLAGS += --sysroot=/home/quantum/RaspberryPi3/sysroot" -early "CONFIG += cross_compile" 'LIBS += -L/home/quantum/RaspberryPi3/libicu60/build-icu-rpi/icu-build/lib -licui18n -licuuc -licudata' 'INCLUDEPATH *= /home/quantum/RaspberryPi3/libicu60/build-icu-rpi/icu-build/include' 'LIBS += -ldl' /home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/config.tests/unix/icu
- cd /home/quantum/RaspberryPi3/qt-5.9/sources2/config.tests/unix/icu && MAKEFLAGS= /usr/bin/make
/home/quantum/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=/home/quantum/RaspberryPi3/sysroot --sysroot=/home/quantum/RaspberryPi3/sysroot -O2 -std=gnu++11 -Wall -W -fPIC -I/home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/config.tests/unix/icu -I. -I/home/quantum/RaspberryPi3/libicu60/build-icu-rpi/icu-build/include -I/home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/mkspecs/devices/linux-rasp-pi3-g++ -o icu.o /home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/config.tests/unix/icu/icu.cpp
/home/quantum/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/quantum/RaspberryPi3/sysroot --sysroot=/home/quantum/RaspberryPi3/sysroot -Wl,-O1 -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/opt/vc/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/lib/arm-linux-gnueabihf -o icu icu.o -L/home/quantum/RaspberryPi3/libicu60/build-icu-rpi/icu-build/lib -licui18n -licuuc -licudata -ldl
=> source accepted.that is, at the end of the day, it always picks the Raspberry ones.
I tried recompiling the icu taking the architecture options directly from the Qt setup,
CPPFLAGS="-O3 -fno-short-wchar -DU_USING_ICU_NAMESPACE=1 -fno-short-enums -pipe -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard"
but Qt ignores them as well.
Now I'm using the Qt cross-compiled with -no-icu, and they work just fine (no qtwebengine though), but I would like to solve it as well.
This is the part where the make crashes
/home/quantum/RaspberryPi3/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/quantum/RaspberryPi3/sysroot -Wl,--gc-sections -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialport/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/opt/vc/lib -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/quantum/RaspberryPi3/sysroot/lib/arm-linux-gnueabihf -o ../../../bin/canbusutil .obj/main.o .obj/readtask.o .obj/canbusutil.o .obj/sigtermhandler.o .obj/moc_readtask.o .obj/moc_canbusutil.o .obj/moc_sigtermhandler.o -L/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialbus/lib -lQt5SerialBus -L/home/quantum/RaspberryPi3/qt-5.9/sources2/qtbase/lib -lQt5Core -lpthread
/home/quantum/RaspberryPi3/sysroot/usr/lib/arm-linux-gnueabihf/libicui18n.so.57: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit status
Makefile:92: recipe for target '../../../bin/canbusutil' failed
make[4]: *** [../../../bin/canbusutil] Error 1
make[4]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialbus/src/tools/canbusutil'
Makefile:44: recipe for target 'sub-canbusutil-make_first' failed
make[3]: *** [sub-canbusutil-make_first] Error 2
make[3]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialbus/src/tools'
Makefile:97: recipe for target 'sub-tools-make_first' failed
make[2]: *** [sub-tools-make_first] Error 2
make[2]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialbus/src'
Makefile:46: recipe for target 'sub-src-make_first' failed
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory '/home/quantum/RaspberryPi3/qt-5.9/sources2/qtserialbus'
Makefile:230: recipe for target 'module-qtserialbus-make_first' failed
make: *** [module-qtserialbus-make_first] Error 2I will try to recompile the icu with different options.