[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-pcre and -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, icu seems disabled, and pcre and zlib should be statically linked in the Qt libraries.

    After that, I run make and look at the built libQt5Core.so and libQt5Gui.so libraries with ldd. Here is the ldd output 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, libz and pcre, despite my configuration. I will not post the output of ldd for libQt5Core.so but it depends on pcre too (just 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!


  • Lifetime Qt Champion

    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 icu at 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 configure broken, in that case?


  • Lifetime Qt Champion

    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-rpath argument from the call to configure, thinking it might help but it did not. QtGui still links with the system's QtCore and with icu.


  • Lifetime Qt Champion

    Try calling ldd like this:

    LD_LIBRARY_PATH=$PWD ldd ./libQt5Gui.so



  • That seems to make icu disappear from the list of dependencies of QtGui. I did not know that ldd lists all the dependencies recursively. I guess you learn something new every day. Thanks a lot!

    However, the dependency for the system's pcre remains. Shouldn't pcre be linked statically into the Qt libraries with the -qt-pcre argument?

    Looking at the so files withreadelf -Wa libQt5Gui.so | grep NEEDED reveals the real dependencies of the library, and they are only 4. libQt5Core.so, though, has more but does not list pcre as one of them, so I assume it should be a recursive one (like the icu was). I wonder what causes that to be output by ldd and whether it is really needed?



  • It turns out that pcre comes from libglib-2.0.so and both ldd and readelf on it reveal that. So I guess mystery solved.

    I will mark this topic as [solved] and thank you @SGaist for your help!


  • Lifetime Qt Champion

    IIRC, QtCore will also use pcre for QRegularExpression


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.