11

I am trying to compile the Qt 5 libraries for my RPI, but it always crashes.

These are the guides I have tried to follow:

http://qt-project.org/wiki/RaspberryPi_Beginners_guide
http://qt-project.org/wiki/RaspberryPi

I have downloaded the cross-compiler and sysroot-image according to the guide and pulled the Qt5 sources from the git repo.

After following one of the guides I am now stuck at make.

This is the error I am receiving:

.obj/release-shared/qlibrary_unix.o: In function `QLibraryPrivate::load_sys()':
qlibrary_unix.cpp:(.text+0xf84): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen':
(.text+0xc): undefined reference to `__dlopen'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlclose.o): In function `dlclose':
(.text+0x0): undefined reference to `__dlclose'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): In function `dlsym':
(.text+0xc): undefined reference to `__dlsym'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.a(dlerror.o): In function `dlerror':
(.text+0x0): undefined reference to `__dlerror'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libm.a(feholdexcpt.o): In function `feholdexcept':
(.text+0x48): undefined reference to `_dl_hwcap'
/home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libm.a(fesetenv.o): In function `fesetenv':
(.text+0x64): undefined reference to `_dl_hwcap'
collect2: virhe: ld:n paluuarvo oli 1                                           # collect2: error: ld returnvalue was 1
make[2]: *** [../../lib/libQt5Core.so.5.0.0] Virhe 1                            # Error 1
make[2]: Poistutaan hakemistosta "/home/esa/qtonpi/qt5/qtbase/src/corelib"      # Leaving directory
make[1]: *** [sub-corelib-make_first] Virhe 2                                   # Error 2
make[1]: Poistutaan hakemistosta "/home/esa/qtonpi/qt5/qtbase/src"              # Leaving directory
make: *** [sub-src-make_first] Virhe 2                                          # Error 2

5 Answers 5

12

Fix the paths of the libraries in your sysroot. Some libraries are symlinks to absolute paths which are broken when placed in your system. Check something like /home/esa/qtonpi/rpi_image/usr/lib/arm-linux-gnueabihf/libdl.so or similar. You should see those are broken symlinks to absolute paths. Fix all of those. In the documents you reported a script for this purpose is provided. Did you run it (https://gitorious.org/cross-compile-tools/cross-compile-tools/blobs/master/fixQualifiedLibraryPaths)?

Try also to check this if you still encounter troubles: I wrote down some notes compiling a recent version from the git for the wheezy image.

4
  • Thanks. I had already ran fixQualifiedLibraryPaths, but on a different sysroot! I couldn't figure that I hadn't ran it on this one...
    – varesa
    Nov 29, 2012 at 14:26
  • I had a different problem: 1/ I've build my own cross-compiler but forgot to indicate it required C++, 2/ bumped into not having a C++ compiler and then discovered a cross-compiler package is available here: github.com/raspberrypi/tools, 3/ I didn't run ./fixQualifiedLibraryPaths again that didn't run correctly in the first place but unfortunately didn't produce an error message. Jan 15, 2013 at 0:56
  • I also used the same link as the OP, and I run fixQualifiedLibraryPaths, however it did not find any paths to fix. There are no libdl and libm at all in my /mnt/rasp-pi-rootfs/usr/lib/
    – vsz
    Oct 21, 2015 at 4:56
  • Then... probably that is the problem? Oct 21, 2015 at 8:29
3

An answer for those who tried both the existing answers and they didn't work:

It might happen that the Raspbian image you downloaded doesn't contain symlinks for libdl and libdm in the /usr/lib/ folder.

In that case the fixQualifiedLibraryPaths won't help you as it can't find the symlinks. Copying libdl.so and libm.so might also fail, for example, if you use a flash drive to copy data from your existing Raspberry Pi, it won't copy them as symlinks, but will copy the libraries themselves. However, for the build to succeed, it seems to require symlinks.

I looked at what libdl and libdm in the /usr/lib/ folder of my Raspberry Pi point at

cd /usr/lib/arm-linux-gnueabihf/
ls -l libld.so libm.so

Do the same for the found files until they are no longer symlinks but normal files.

On my system it turned out they are called libdl-2.13.so and libm-2.13.so and reside in /lib/arm-linux-gnueabihf/ instead of /usr/lib/...

Going back to my PC, I found these exact files in the /lib/arm-linux-gnueabihf/ folder (if you don't find them, you can copy them from your Raspberry Pi). So I created symlinks for them in the /usr/lib/arm-linux-gnueabihf/ folder :

sudo ln -s /lib/arm-linux-gnueabihf/libdl-2.13.so /usr/lib/arm-linux-gnueabihf/libdl.so
sudo ln -s /lib/arm-linux-gnueabihf/libm-2.13.so /usr/lib/arm-linux-gnueabihf/libm.so

After this, qtbase was compiled successfully.

(note, that in order to continue to cross-compile from Qt, you have to keep the image of your SD card mounted on your PC (as described in the guide), but that's not enough: you have to mount it before starting Qt Creator)

2

Try this

ln -s /mnt/raspberry-rootfs/lib/arm-linux-gnueabihf /lib/

Basically it seems that absolute path(s) have been specified when the so files on the Pi were linked (/lib/), and therefore in the /mnt/raspberry-rootfs they are broken.

Linking the Pi's /lib/arm-linux-gnueabihf to the Pc's /lib directory fixes the wrong linking and allows QT to compile. It's a dirty trick but it works.

If you don't have libdl/ libm on the Pi, then you need to stick the SD card back into the Pi, boot and install them. Obviously you will need to create a new image on the PC from the SD Card and mount it on /mnt/raspberry-rootfs

1

This could be because libdl.so and libm.so are missing from your local rootfs/usr/lib/arm-linux-gnueabihf directory (there are only libdl.a and libm.a). Copying the two files from the Raspberry Pi should make the compilation successful.

1
  • Yeah, for newcomers posting answers is the only possible way though. Time to get some rep so you can start commenting :)
    – varesa
    Apr 25, 2014 at 13:13
1

instead of fixQualifiedLibraryPaths use:

cd <folder-with-sysroot-subfolder>
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/script/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysroot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.