Show library dependencies

From Qt Wiki
Revision as of 17:45, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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 page 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!

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!

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:

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

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. [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

DependsCreator

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:

From the command prompt you may start either depends.exe or directly your application.exe. With all accompanying dlls in the same folder, the application will start and should without problems.

Categories: