Solved How to change LFLAGS of result Makefile ? (can't find libs with non-standard prefix)
-
Hi. I've got a trouble: compiler can't find needed shared libs, which placed to the non-standard folder. Event LD_LIBRARY_PATH defined and added -L instrunction. By default it looks folder /usr/lib, but needed libs are placed to /usr/lib/arm-linux-gnueabihf.
Here is my variables:export PATH="$SDK_PATH_NATIVE/bin:$PATH" export PKG_CONFIG_SYSROOT_DIR=/ export PKG_CONFIG_LIBDIR="$SDK_PATH_TARGET/usr/lib/pkgconfig" export CFLAGS=" --sysroot=$SDK_PATH_TARGET" export CPPFLAGS=$CFLAGS export CXXFLAGS=$CPPFLAGS export LDFLAGS=" --sysroot=$SDK_PATH_TARGET -L/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf" export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf
Qt config:
-opensource -confirm-license \ -developer-build \ -device imx6 \ -device-option CROSS_COMPILE="$TOOLCHAIN_PREFIX" \ -sysroot "$SDK_PATH_TARGET" \ -prefix "$QTDIR" \ -nomake tools \ -nomake tests \ -nomake examples \ -no-use-gold-linker \ -recheck \ -verbose \ -L /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf \ -rpath \ -qt-zlib \ -opengl es2
config.log:
... > arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs -o opengl_es2 main.o -L/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf -L//home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf -lGLESv2 > /home/imx6/Desktop/TN_UBUNTU_MOD/cache/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libXdamage.so.1, needed by /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/libGAL.so, not found (try using -rpath or -rpath-link) > /home/imx6/Desktop/TN_UBUNTU_MOD/cache/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libXfixes.so.3, needed by /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/libGAL.so, not found (try using -rpath or -rpath-link) > /home/imx6/Desktop/TN_UBUNTU_MOD/cache/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libXext.so.6, needed by /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/libGAL.so, not found (try using -rpath or -rpath-link) > /home/imx6/Desktop/TN_UBUNTU_MOD/cache/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libX11.so.6, ...
but, for example, libXdamage.so.1 is exists:
$ ls //home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf | grep libXdamage libXdamage.a libXdamage.so libXdamage.so.1 libXdamage.so.1.1.0
What I'm doing wrong?
Thanks! -
AFAIK the -L option cannot be used there.
Checkout the recommendation in the warning
@r3d9u11 said in Can't find libs with non-standard prefix:rootfs/usr/lib/libGAL.so, not found (try using -rpath or -rpath-link)
and try using -rpath and -rpath-link (see syntax here ftp://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html )
-
@koahnig Thanks for answer! I removed LD_LIBRARY_PATH and changed LDFLAGS to:
export LDFLAGS=" --sysroot=$SDK_PATH_TARGET -Wl,-rpath-link,/lib/arm-linux-gnueabihf -Wl,-rpath-link,/usr/lib/arm-linux-gnueabihf"
but Qt doesn't pass this value to gcc:
> arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs -o opengl_es2 main.o -lGLESv2 -lEGL -lGAL > /home/imx6/Desktop/TN_UBUNTU_MOD/cache/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: librt.so.1, needed by /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf/libGLESv2.so, not found (try using -rpath or -rpath-link)
where I should to define rpath?
-
Possibly in your congif line:
@r3d9u11 said in Can't find libs with non-standard prefix:
Qt config:
-opensource -confirm-license
-developer-build
-device imx6
-device-option CROSS_COMPILE="$TOOLCHAIN_PREFIX"
-sysroot "$SDK_PATH_TARGET"
-prefix "$QTDIR"
-nomake tools
-nomake tests
-nomake examples
-no-use-gold-linker
-recheck
-verbose
-L /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf
-rpath
-qt-zlib
-opengl es2change to
-opensource -confirm-license \ -developer-build \ -device imx6 \ -device-option CROSS_COMPILE="$TOOLCHAIN_PREFIX" \ -sysroot "$SDK_PATH_TARGET" \ -prefix "$QTDIR" \ -nomake tools \ -nomake tests \ -nomake examples \ -no-use-gold-linker \ -recheck \ -verbose \ -rpath /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf \ -qt-zlib \ -opengl es2
or eventually change -rpath to -rpath-link
NOTE: I am on really thin ice here, since I am not sure, if it may work at all.
-
@koahnig I tried rpath and rpath-link, nothing changes (because Qt doesn't pass LDFLAGS to GCC, as it shows in config.log).
-rpath as a Qt's parameter doesn't accept any values (it is just a key, and uses for another goals, as I think):... o qfilesystemiterator_unix.o qfsfileengine_unix.o qlocale_unix.o qlibraryinfo.o -Wl,--gc-sections Info: creating cache file /home/imx6/Desktop/TN_UBUNTU_MOD/cache/qtbase/.qmake.cache ERROR: Invalid command line parameter '/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf'.
-
This is the part of qtbase/config.tests/opengl_es2/Makefile:
... LFLAGS = -mfloat-abi=hard --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs --sysroot=/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs LIBS = $(SUBLIBS) /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf/libGLESv2.so /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf/libEGL.so /home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/libGAL.so ...
I tried to define variable QMAKE_LFLAGS before configuring:
export QMAKE_LFLAGS=" -Wl,-rpath,/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf"
but nothing changes, this parameters wasn't added to variable LDFLAGS of Makefile.
So, how does qmake produce Makefile, which environment variables are involved in that process?
-
Ok, I added two lines to ....../linux-imx6-g++/qmake.conf:
QMAKE_LFLAGS += -Wl,-rpath-link,/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/lib/arm-linux-gnueabihf QMAKE_LFLAGS += -Wl,-rpath-link,/home/imx6/Desktop/TN_UBUNTU_MOD/tmpmnt/rootfs/usr/lib/arm-linux-gnueabihf
and it all needed libs were found.
but the head question is still opened: how can I to define all lib srcs (for example via linker flags) without modifications of the qmake.conf?
Any ideas? Thanks!
-
You can use
QMAKE_RPATHDIR
to change the rpaths used by your application. -
@SGaist Where this variable should be defined?
-
In your .pro file.
-
@SGaist I haven't any .pro file, I'm looking for way without any modifications of original ".qmake" file. Unfortunally there is no such way, as I think.
Howewer, thanks for hint!
Finally I did a workaround in my script:if [ ! -f "qtbase/mkspecs/devices/linux-imx6-g++/imx6-qmake.conf" ]; then mv "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" "qtbase/mkspecs/devices/linux-imx6-g++/imx6-qmake.conf" echo "include(./imx6-qmake.conf)" > "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" echo "QMAKE_RPATHDIR += $SDK_PATH_TARGET/lib/arm-linux-gnueabihf" >> "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" echo "QMAKE_RPATHDIR += $SDK_PATH_TARGET/usr/lib/arm-linux-gnueabihf" >> "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" fi
or:
if [ ! -f "qtbase/mkspecs/devices/linux-imx6-g++/imx6-qmake.conf" ]; then mv "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" "qtbase/mkspecs/devices/linux-imx6-g++/imx6-qmake.conf" echo "include(./imx6-qmake.conf)" > "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" echo "QMAKE_LFLAGS += -Wl,-rpath-link,$SDK_PATH_TARGET/lib/arm-linux-gnueabihf" >> "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" echo "QMAKE_LFLAGS += -Wl,-rpath-link,$SDK_PATH_TARGET/usr/lib/arm-linux-gnueabihf" >> "qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf" fi