[Solved]Building QtGui links it dynamically to icu, pcre and zlib, even though it is configured not to
I am trying to build Qt on linux with as few dependencies to any other libraries as possible. However, configuring with
-qt-zlib(among other switches) still makes QtGui link dynamically against those particular libraries, as shown by
ldd. 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-pulseaudio
This 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, and
zlibshould be statically linked in the Qt libraries.
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
pcre, despite my configuration. I will not post the output of
lddfor libQt5Core.so but it depends on
pcre, 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 on
icuat all. Yet they do (at least QtGui). I do not want my Qt to depend on
icu(and the rest of the libraries that I mention in my post). Can I remove that dependency somehow and is the
configurebroken, 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.
lyubomirv last edited by
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 to
configure, thinking it might help but it did not. QtGui still links with the system's QtCore and with
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 that
lddlists all the dependencies recursively. I guess you learn something new every day. Thanks a lot!
However, the dependency for the system's
pcrebe linked statically into the Qt libraries with the
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 list
pcreas one of them, so I assume it should be a recursive one (like the
icuwas). I wonder what causes that to be output by
lddand whether it is really needed?
It turns out that
readelfon it reveal that. So I guess mystery solved.
I will mark this topic as [solved] and thank you @SGaist for your help!
IIRC, QtCore will also use pcre for QRegularExpression