Linking issues with Qt 5.2.1 when building for ARM



  • Hi everyone,

    I'm building Qt 5.2.1 for ARM/Linux/X11.
    My target platform is Nvidia Tegra 2 and I configured Qt with the following command (sorry, it's pretty long):

    @./configure -prefix /opt/QtTegra2 -opensource -confirm-license -mtdev -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds -no-glib -make libs -nomake examples -no-cups -no-pch -no-dbus -device tegra2 -device-option CROSS_COMPILE=/opt/local/bin/arm-linux-gnueabihf- -no-eglfs -no-directfb -no-linuxfb -no-kms -qpa xcb -sysroot /home/siro/ubuntu/rootfs -opengl es2 2>&1 | tee configure.log@

    After compiling the components of libQt5Core.so comes the linking issue.
    The resulting error follows:

    @/opt/local/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: /home/siro/ubuntu/rootfs/usr/lib/arm-linux-gnueabihf/libz.a(compress.o): relocation R_ARM_THM_MOVW_ABS_NC against a local symbol can not be used when making a shared object; recompile with -fPIC
    /home/siro/ubuntu/rootfs/usr/lib/arm-linux-gnueabihf/libz.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status@

    I'm kind of lost since I couldn't find any solution to this issue.

    Any help?

    PS: -fPIC is among the options employed to compile objects since I'm not using the -static option of the configure script and the pkgconfig of libz inside usr/lib/arm-linux-gnueabihf/pkgconfig seems correct.



  • Adding -static to the configuration option (after a make clean) brings up other issues...



  • I've done some additional testing, with the same flags except for -device, -device-option, -no-neon, and -sysroot I can safely compile for x86.



  • A litte late but i found the problem/solution:

    The problem is the sysroot. Normally gcc links to shared libraries. But when it cant find it, gcc uses the static libraries (.a). When you look in [sysroot]/usr/lib/arm-linux-gnueabihf the shared libraries are not in this place. There are only symlinks to /lib/arm-linux-gnueabihf. So gcc looks for the shared libraries on you host-pc, where it can not find them.

    Solution:
    Create just the right symlink. (here an example for your libz, the X is the version number)
    ln -s [sysroot]/lib/arm-linux-gnueabihf/libz.so.X [sysroot]/usr/lib/arm-linux-gnueabihf/libz.so
    (Dont forget to remove the old symlink and create it after compiling successfully; i just mv the symlink from "file.so" to "file.so.backup" befor compiling)

    Another solution:
    Relativ symlink.
    ln -s ../../../lib/arm-linux-gnueabihf/libz.so.X [sysroot]/usr/lib/arm-linux-gnueabihf/libz.so


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.