Wrong link paths at cross-compiling Qt 5.15.2
-
Hello.
I have a small problem. Compiled Qt from source.../qt5.15.2/qtbase/configure -release -no-gui -device linux-xilinx7020-g++ -device-option CROSS_COMPILE=~/Documents/compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ../sysroot -prefix /opt/Qt/5.15.2 -extprefix ../ready-qt -hostprefix ../tools-qt -opensource -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine -nomake tests -make libs -pkg-config -no-use-gold-linker -v -no-gcc-sysroot -no-dbus
It was assumed that executable file would be linked with Qt library at address specified in the variable PREFIX = /opt/Qt/5.15.2, and all other system libraries would be taken at addresses from the sysroot. But when I calling ldd on the target machine, Qt library is linked using the standard path.
[test@localhost bin]$ ldd testFirmware libQt5SerialPort.so.5 => /usr/lib/libQt5SerialPort.so.5 (0xb6f62000) libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0xb6b9c000) libpthread.so.0 => /lib/libpthread.so.0 (0xb6b77000) libatomic.so.1 => /usr/lib/libatomic.so.1 (0xb6b60000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb6a4d000) libm.so.6 => /lib/libm.so.6 (0xb69cd000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb69a4000) libc.so.6 => /lib/libc.so.6 (0xb68ab000) libudev.so.1 => /lib/libudev.so.1 (0xb6882000) /lib/ld-linux-armhf.so.3 (0xb6f9c000) libz.so.1 => /lib/libz.so.1 (0xb685f000) libicui18n.so.65 => /usr/lib/libicui18n.so.65 (0xb6673000) libicuuc.so.65 => /usr/lib/libicuuc.so.65 (0xb652b000) libdl.so.2 => /lib/libdl.so.2 (0xb6518000) libpcre2-16.so.0 => /lib/libpcre2-16.so.0 (0xb64af000) libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0xb63ca000) libicudata.so.65 => /usr/lib/libicudata.so.65 (0xb490a000) libpcre.so.3 => /lib/libpcre.so.3 (0xb48c6000)
How to fix it? I need solution that all Qt-related libraries use the path from PREFIX (do not add each library manually). Maybe need add something into pro file or change something in the qmake settings file.
Thanks in advance.
-
Hi,
You can set the LD_LIBRARY_PATH environment variable before starting your application. Otherwise, if memory serves well, you need to configure the rpath when building your application. See QMAKE_RPATHDIR.