Linker error: Undefined reference error _dl_stack_flags with Qt 5.12.5 crosscompiler(Raspberry PI3) and pthreads
-
I'm trying to include the libusb-1.0 library in order to use it in the Qt 5.12.5 project for Raspberry PI3. I built a cross-compiler for Raspberry Pi3 under Ubuntu, the cross-compiler works fine. When I added the libusb library to the project (added the
LIBS += -lusb-1.0 -ludev -L/home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf -ldl in the pro file), included the libusb.h header file, and built, I got errors from the linker(for -lpthread library): 17:17:14: Starting: "/usr/bin/make" -j6 /home/vboxuser/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/vboxuser/raspi/sysroot -Wl,-rpath,/home/vboxuser/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/usr/lib/arm-linux-gnueabihf -Wl,-rpath,/home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath,/usr/local/qt5pi/lib -Wl,-rpath-link,/home/vboxuser/raspi/sysroot/opt/vc/lib -Wl,-rpath-link,/home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/vboxuser/raspi/sysroot/lib/arm-linux-gnueabihf -o usbCashboxExchange main.o mainwindow.o qml_settings.o usbClass.o moc_mainwindow.o moc_qml_settings.o moc_usbClass.o -L/home/vboxuser/raspi/sysroot/opt/vc/lib -lusb-1.0 -ludev -L/home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf -ldl /home/vboxuser/raspi/qt5pi/lib/libQt5Widgets.so /home/vboxuser/raspi/qt5pi/lib/libQt5Gui.so /home/vboxuser/raspi/qt5pi/lib/libQt5Core.so /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so -lpthread /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a(pthread_create.o): In function `__pthread_create_2_1': /build/glibc-lsttuD/glibc-2.28/nptl/pthread_create.c:697: undefined reference to `_dl_stack_flags' /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function `__pthread_initialize_minimal_internal': /build/glibc-lsttuD/glibc-2.28/nptl/nptl-init.c:434: undefined reference to `_dl_pagesize' /build/glibc-lsttuD/glibc-2.28/nptl/nptl-init.c:434: undefined reference to `_dl_init_static_tls' /build/glibc-lsttuD/glibc-2.28/nptl/nptl-init.c:434: undefined reference to `_dl_wait_lookup_done' /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function `__pthread_get_minstack': /build/glibc-lsttuD/glibc-2.28/nptl/nptl-init.c:443: undefined reference to `_dl_pagesize' /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a(unwind.o): In function `unwind_stop': /build/glibc-lsttuD/glibc-2.28/nptl/unwind.c:72: undefined reference to `__pointer_chk_guard_local' collect2: error: ld returned 1 exit status make: *** [Makefile:162: usbCashboxExchange] Error 1 17:17:14: The process "/usr/bin/make" exited with code 2. Error while building/deploying project usbCashboxExchange (kit: Qt 5.12.5 (qt5)) When executing step "Make"
As far as I understand, the linker complains about the lack of a library libdl, but both the static library libdl.a and the dynamic library libdl.so are definitely on the path: -L /home/vboxuser/raspi/sysroot/usr/lib/arm-linux-gnueabihf. Why can't the linker see them? The most interesting thing is that if I switch to GCC 64-bit compiler kit, then everything compiles normally, even it’s enough to specify only one LIBS += -lusb-1.0 library whithout other dependencies and that’s it - is this due to the fact that the linkers work differently in different kits? How solve this linker errors?
-
Undefined reference rather points at a missing include statement or a compatibility issue.
Furthermore, 5.12 is EOL and out of support. Maybe upgrading to Qt 6 solves the issue by itself.