gcc linking shared libraries with dependent libraries-Collection of common programming errors

I have a complicated project with multiple executable targets and multiple shared libraries. The shared libraries currently don’t have their dependent shared libraries linked in, and the result is that linker arguments to build the executables are hideously long and hard to maintain. I’d like to add in the dependencies so the Makefiles become much cleaner.

I want to add the following (example):

gcc -shared -o libshared.so -lshared_dependent1 -lshared_dependent2 objfile1.o objfile2.o

Is there a way to test if all the symbols in libshared.so will resolve based on that line? Is there a way to print out if any of the shared_dependent libraries specified were unnecessary?

Thanks in advance.

  1. I know how to force no undefined symbols:

    -Wl,--no-undefined
    

    As autotools often complains about this missing on Windows.

    I do not know if it is possible to check if there are any unused libraries, other than leaving them out one by one.

Originally posted 2013-11-09 22:47:24.