This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: How to list all libraries that were used for linking a binary?



Tool/software: TI C/C++ Compiler

I need to know which libraries/archives (absolute paths) were used during linking of my library. How to do that with cl6x compiler/linker?

With GCC I am able to use -Wl,--verbose, which (after some postprocessing) will show me list:

$ echo "int main(){}" | gcc -xc++ - -lz -Wl,--verbose | grep succeeded
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o succeeded
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o succeeded
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o succeeded
attempt to open /tmp/ccJQpZK8.o succeeded
attempt to open /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libz.so succeeded
...


  • To further clarify my use case: I need some way to determine dependencies a binary has (similarly to header dependencies for an object, but I need this for a library).
  • Here are two methods to consider.

    One is to inspect the linker map file.  This is a text file produced by the linker when you use the option --map_file=file_name_here . The option can also be abbreviated to -m .  If you build with CCS, the map file is usually name_of_project.map .  The map file does not list, all in one place, the libraries used.  Rather, the library names appear as object files within those libraries contribute code and data to the program.  

    Another method is to use the utility lib_footprint from the cg_xml package.  The intended purpose of this utility is to show how much memory is used by each library.  As a side effect, though, it lists all the libraries used in the program.

    Thanks and regards,

    -George

  • Thanks for your quick reply.

    Map file does not store information about location of a library (from where object has been taken) on disk, so that is not satisfying my need.

    However I've found the following option in cl6x, and in that resulting xml file I see full paths for all libraries that were used during linking (however I'd appreciate if you have something more lightweight):

    --xml_link_info,-xml_link_info=file
    Detailed link information data-base into <file>

    Sorry for not telling that earlier (if that makes any difference): I am using CGT 7.3.23 (on linux).

  • I didn't realize you need to see the full path to each library.  

    With regard to the option --xml_link_info=file, you say ...

    Bartlomiej Kucharczyk said:
    in that resulting xml file I see full paths for all libraries that were used during linking (however I'd appreciate if you have something more lightweight)

    Unfortunately, we do not.  

    Note the cg_xml package comes with the Perl source code for every utility.  You might consider modifying lib_footprint to print out the libraries found, including the path.

    Thanks and regards,

    -George