[Solved]Building QtGui links it dynamically to icu, pcre and zlib, even though it is configured not to
-
Hello,
I am trying to build Qt on linux with as few dependencies to any other libraries as possible. However, configuring with
skip qtwebkit-no-icu-qt-pcreand-qt-zlib(among other switches) still makes QtGui link dynamically against those particular libraries, as shown byldd. I am building on XUbuntu 14.04.2 LTS.Here is how I run configure:
./configure -opensource -confirm-license -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -nomake tools -nomake examples -no-largefile -no-qml-debug -skip qtconnectivity -skip qtwebkit -skip qtquick1 -no-rpath -no-openssl -qt-zlib -no-libjpeg -no-libpng -no-gif -no-harfbuzz -no-xinput2 -gtkstyle -qt-xkbcommon -qt-freetype -no-fontconfig -qt-pcre -no-compile-examples -no-nis -no-cups -no-iconv -no-evdev -no-icu -qt-xcb -no-linuxfb -no-opengl -no-sql-sqlite -no-sql-psql -no-egl -no-alsa -no-pulseaudioThis is an excerpt from the configure summary, related to the said libraries:
Support enabled for: ICU .................... no PCRE ................... yes (bundled copy) zlib ................... yes (bundled copy)As you can see,
icuseems disabled, andpcreandzlibshould be statically linked in the Qt libraries.After that, I run
makeand look at the built libQt5Core.so and libQt5Gui.so libraries withldd. Here is thelddoutput for libQt5Gui.so:linux-vdso.so.1 => (0x00007ffc0f9ce000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f17874f1000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f17871ed000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1786ee6000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1786b21000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1786903000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f17866e9000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f17862e2000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f1785f69000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1785d64000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f1785a5c000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1785854000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f178563d000) /lib64/ld-linux-x86-64.so.2 (0x00007f1787ffd000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f1783dd0000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f1783b91000)As you can see, QtGui depends on the system's
icu,libzandpcre, despite my configuration. I will not post the output oflddfor libQt5Core.so but it depends onpcretoo (justpcre, not on the others).Am I doing something wrong? How can I make Qt not link dynamically to those libraries? Tell me if you need any other information. I will appreciate any help with that!
-
Hi and welcome to devnet,
IIRC, when calling ldd (or loading a library normally), the loader searches for libraries in paths configured in ld.so.config (or something similar in /etc) so I suspect that /usr/lib/x86_64-linux-gnu is searched prior to the Qt install path so it will use these.
-
Hi and thanks!
You are right that the order of searching for libraries is defined by ld.so.conf in /etc. However, my problem is not where Qt looks for the libraries but why at all does it look for and link to them.
As you see, I have configured using
-no-icu. So I expect the Qt libraries to not depend onicuat all. Yet they do (at least QtGui). I do not want my Qt to depend onicu(and the rest of the libraries that I mention in my post). Can I remove that dependency somehow and is theconfigurebroken, in that case? -
Just realized when re-reading the output: the ICU linking you see is because the libQt5Core.so.5 you are seeing is the one installed by your distribution.
-
Hm, I have noticed that too but did not pay much attention to it.
So how do I tell Qt to link with my own libQt5Core.so? I tried removing the
-no-rpathargument from the call toconfigure, thinking it might help but it did not. QtGui still links with the system's QtCore and withicu. -
Try calling ldd like this:
LD_LIBRARY_PATH=$PWD ldd ./libQt5Gui.so -
That seems to make
icudisappear from the list of dependencies of QtGui. I did not know thatlddlists all the dependencies recursively. I guess you learn something new every day. Thanks a lot!However, the dependency for the system's
pcreremains. Shouldn'tpcrebe linked statically into the Qt libraries with the-qt-pcreargument?Looking at the so files with
readelf -Wa libQt5Gui.so | grep NEEDEDreveals the real dependencies of the library, and they are only 4. libQt5Core.so, though, has more but does not listpcreas one of them, so I assume it should be a recursive one (like theicuwas). I wonder what causes that to be output bylddand whether it is really needed? -
IIRC, QtCore will also use pcre for QRegularExpression