Reducing library dependancies

Adriaan de Groot groot at kde.org
Fri Aug 1 14:56:21 BST 2008


On Friday 01 August 2008 15:40:10 John Tapsell wrote:
>   Does anyone know how to get a list of libraries that a program links
> against but doesn't actually use?  I've been playing about with  'ldd

Wouldn't the cmake 2.6 changes, which reduce linking against indirect 
dependencies, already clean some of this up?

On the Solaris side of the fence we use a whole bunch of linker flags to make 
the linker do the weeding-out when the executable is constructed, and after 
that dump -Lv gives useful results:

/opt/kde-4.0/bin/ksysguard:
[1]     NEEDED          libc.so.1
[2]     NEEDED          libpthread.so.1
[3]     NEEDED          librt.so.1
[4]     NEEDED          libCrun.so.1
[5]     NEEDED          libkdeinit4_ksysguard.so

/opt/kde-4.0/lib/libkdeinit4_ksysguard.so:
[1]     NEEDED          libc.so.1
[2]     NEEDED          libpthread.so.1
...
[15]    NEEDED          libQtDBus.so.4
[16]    NEEDED          libQtGui.so.4

Well, and I can go on following the libraries used, or let ldd sort it out for 
me; keeping each library down to the minimal NEEDED set means that the ldd 
output reflects those libs that we really do use.

Now all you need is the same data from your system and you can do a set 
difference to find out what's not used.


-- 
Adriaan de Groot     
http://ev.kde.org/   - Supporting Free Software KDE Development




More information about the kde-core-devel mailing list