Show library dependencies: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Cleanup)
m (Typo (plus dummy edit to bypass spam filter: it does not like 888).)
 
Line 1: Line 1:
{{LangSwitch}}
{{LangSwitch}}
[[Category:Developing with Qt]]
[[Category:Developing with Qt]]
The tools used to detect the libraries an executable or another shared library depends on are highly platform dependend. Find the tools for various systems (and basic usage for some of them) listed below.
The tools used to detect the libraries an executable or another shared library depends on are highly platform-dependent. Find the tools for various systems (and basic usage for some of them) listed below.


Be aware that the tools not necessarily show you '''all''' the libraries you need! It's best to separately check the dependency libraries too.
Be aware that the tools not necessarily show you '''all''' the libraries you need! It's best to separately check the dependency libraries too.
Line 34: Line 34:
  libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007feb78e11000)
  libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007feb78e11000)
  libstdc.so.6 => /usr/lib/libstdc.so.6 (0x00007feb78b06000)
  libstdc.so.6 => /usr/lib/libstdc.so.6 (0x00007feb78b06000)
  libm.so.6 => /lib/libm.so.6 (0x00007feb78885000)
  libm.so.6 => /lib/libm.so.6 (0x00007feb78875000)
  libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007feb78677000)
  libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007feb78677000)
  libc.so.6 => /lib/libc.so.6 (0x00007feb78315000)
  libc.so.6 => /lib/libc.so.6 (0x00007feb78315000)

Latest revision as of 10:36, 24 April 2016

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

The tools used to detect the libraries an executable or another shared library depends on are highly platform-dependent. Find the tools for various systems (and basic usage for some of them) listed below.

Be aware that the tools not necessarily show you all the libraries you need! It's best to separately check the dependency libraries too.

Watch out for plugins, that might pull in further dependencies!

The wiki article Qt Library Cross Dependencies lists some of the cross dependencies of the Qt libraries.

Linux

Linux uses the "ldd" command to show the libraries that are linked to an executable or another shared library:

ldd prints the path to the library and some address after the =>. "not found" is printed in case the library is missing.

Be aware: The libraries are not sorted by name in the output!

$ ldd myFancyProgram
 linux-vdso.so.1 => (0x00007fffd6d17000)
 libcurl-gnutls.so.4 => /usr/lib/libcurl-gnutls.so.4 (0x00007feb7c45a000)
 libMagick+''.so.10 => /usr/lib/libMagick.so.10 (0x00007feb7c1e3000)
 libWand.so.10 => /usr/lib/libWand.so.10 (0x00007feb7bf1c000)
 libMagick.so.10 => /usr/lib/libMagick.so.10 (0x00007feb7bb25000)
 libQtAssistantClient.so.4 => /usr/lib/libQtAssistantClient.so.4 (0x00007feb7b91f000)
 libpthread.so.0 => /lib/libpthread.so.0 (0x00007feb7b703000)
 libQtWebKit.so.4 => /usr/lib/libQtWebKit.so.4 (0x00007feb7aa8a000)
 libQtSvg.so.4 => /usr/lib/libQtSvg.so.4 (0x00007feb7a836000)
 libQt3Support.so.4 => /usr/lib/libQt3Support.so.4 (0x00007feb7a30b000)
 libQtXml.so.4 => /usr/lib/libQtXml.so.4 (0x00007feb7a0c2000)
 libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007feb7955c000)
 libQtNetwork.so.4 => /usr/lib/libQtNetwork.so.4 (0x00007feb79253000)
 libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007feb78e11000)
 libstdc.so.6 => /usr/lib/libstdc.so.6 (0x00007feb78b06000)
 libm.so.6 => /lib/libm.so.6 (0x00007feb78875000)
 libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007feb78677000)
 libc.so.6 => /lib/libc.so.6 (0x00007feb78315000)
 libidn.so.11 => /usr/lib/libidn.so.11 (0x00007feb780e3000)
 libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0x00007feb77e9e000)
 libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007feb77c73000)
 libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007feb779dc000)
 libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007feb777b8000)
 libcom_err.so.2 => /lib/libcom_err.so.2 (0x00007feb775b6000)
 libz.so.1 => /usr/lib/libz.so.1 (0x00007feb7739f000)
 libgnutls.so.13 => /usr/lib/libgnutls.so.13 (0x00007feb7711a000)
 liblcms.so.1 => /usr/lib/liblcms.so.1 (0x00007feb76ee6000)
 libtiff.so.4 => /usr/lib/libtiff.so.4 (0x00007feb76c8d000)
 libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00007feb76a6a000)
 libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00007feb76839000)
 libXext.so.6 => /usr/lib/libXext.so.6 (0x00007feb76628000)
 libXt.so.6 => /usr/lib/libXt.so.6 (0x00007feb763c4000)
 libbz2.so.1.0 => /lib/libbz2.so.1.0 (0x00007feb761b4000)
 libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007feb75f36000)
 libdl.so.2 => /lib/libdl.so.2 (0x00007feb75d32000)
 libSM.so.6 => /usr/lib/libSM.so.6 (0x00007feb75b2a000)
 libICE.so.6 => /usr/lib/libICE.so.6 (0x00007feb7590f000)
 libX11.so.6 => /usr/lib/libX11.so.6 (0x00007feb7560c000)
 /lib64/ld-linux-x86-64.so.2 (0x00007feb7c696000)
 libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00007feb753a0000)
 libQtSql.so.4 => /usr/lib/libQtSql.so.4 (0x00007feb75160000)
 libaudio.so.2 => /usr/lib/libaudio.so.2 (0x00007feb74f47000)
 libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00007feb74d22000)
 libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007feb74a62000)
 libXi.so.6 => /usr/lib/libXi.so.6 (0x00007feb74859000)
 libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007feb74650000)
 libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00007feb74449000)
 libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007feb74245000)
 librt.so.1 => /lib/librt.so.1 (0x00007feb7403c000)
 liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0x00007feb73e2e000)
 libresolv.so.2 => /lib/libresolv.so.2 (0x00007feb73c18000)
 libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x00007feb739ff000)
 libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007feb737f8000)
 libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00007feb735f6000)
 libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0x00007feb733e6000)
 libgcrypt.so.11 => /lib/libgcrypt.so.11 (0x00007feb73198000)
 libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007feb72f74000)
 libXau.so.6 => /usr/lib/libXau.so.6 (0x00007feb72d72000)
 libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0x00007feb72b71000)
 libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007feb72956000)
 libpcre.so.3 => /usr/lib/libpcre.so.3 (0x00007feb72730000)
 libgpg-error.so.0 => /lib/libgpg-error.so.0 (0x00007feb7252d000)
 libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007feb72328000)

OS X

Use the "otool" command on OS X to show the libraries that are linked to an executable or another shared library:

Be aware: The libraries are not sorted by name in the output!

$ otool -L menubar.app/Contents/MacOS/menubar
menubar.app/Contents/MacOS/menubar:
 /usr/local/Trolltech/Qt-4.7.0-cocoa/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0-cocoa/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0-cocoa/lib/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0-cocoa/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.0)
 /usr/lib/libstdc.6.dylib (compatibility version 7.0.0, current version 7.9.0)
 /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)

In case you build universal binaries (one big executable with object code for different architectures like x86, x86_64, ppc) your output might look like this:

$ otool -L menubar.app/Contents/MacOS/menubar
menubar.app/Contents/MacOS/menubar (architecture i386):
 /usr/local/Trolltech/Qt-4.7.0/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.0)
 /usr/lib/libstdc.6.dylib (compatibility version 7.0.0, current version 7.9.0)
 /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
menubar.app/Contents/MacOS/menubar (architecture ppc):
 /usr/local/Trolltech/Qt-4.7.0/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.7.0, current version 4.7.0)
 /usr/local/Trolltech/Qt-4.7.0/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.0)
 /usr/lib/libstdc''+.6.dylib (compatibility version 7.0.0, current version 7.9.0)
 /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)

The libraries should be the same for every architecture. You can limit the output for one architecture by adding a "-arch" switch to otool:

$ otool -L -arch i386 menubar.app/Contents/MacOS/menubar

Windows

There is no command line tool for printing the dependencies on Windows. Instead the graphical Dependency Walker tool (depends.exe) is used. The tool was included in Visual Studio until Version 8.0 (aka Visual Studio 2005). It is nowadays downloadable from http://www.dependencywalker.com. It does not require any development environment to be installed and runs on Windows 95, 98, Me, NT, 2000, XP, 2003, Vista, and 7.

Loading an application into the dependency walker will show all the different dlls loaded including their folder. Errors are shown for dlls incompatible or not available. However, this process provides also some wrong indications. The screen shot below shows the output when Qt creator application is loaded. This version of Qt creator has been compiled with MinGW 4.6.2 (32 bit). Unfortunately, Depends.exe indicates missing dlls (such as GPSVC.DLL and IESHIMS.DLL). Apparently the list of missing dlls might grow with time due to updates of Windows. Those dlls are typically not on the system, but they are also not required for proper working of the application. This makes it a bit difficult to find other missing dll which need to be made accessible to the application. This may be achieved either by adding the folder of the dll to the environment path or copying to the application's folder.

TIP: press F9 to see the full path of the dll

More detailed checking of dependencies

depends.exe helps to see from where the dlls have been loaded. However, the ultimate test is starting the application executable with a blank environment.

Start cmd.exe (the command prompt)

Type "path" You will probably see some lengthy expression with a lot folders from your PC. If there is one entry with Qt dlls, you might face a mixup. The same for compiler dlls might happen. Type "set path=", which empty the path environment setting. Type "path" will show "PATH=(null)"

Example output:

Microsoft Windows [Version 6.1.xxxx]
Copyright © 2013 Microsoft Corporation. Alle Rechte vorbehalten.

d:gt;path
PATH=C:Files\Common Files\Microsoft Shared\Windows Live;c:Files (x86)8.70\bin;c:.8.3_MinGW\bin;c:.8.3_MinG
W\lib;C:Files\Common Files\Microsoft Shared\Windows Live;C:32;C:;C:32\Wbem;C:3
2\WindowsPowerShell\v1.0C:Files\Intel\DMIX;C:Files (x86);C:Files (x86)Files\Roxio Shared\10
.0\DLLSharedC:Files\Common Files\Microsoft Shared\Windows Live;C:Files (x86)Files\Teleca Shared;C:Files
 (x86)Leak Detector\bin;C:Files (x86)Files\Roxio Shared\DLLSharedC:Files (x86)2.26.3\bin;C:gram Files\MiKTeX 2.9\miktex\bin\x64C:Files\TortoiseSVN\bin;C:Files (x86);

d:gt;set path=

d:gt;path
PATH=(null)

d:gt;