Can I get a report of ALL the libraries linked when building my C++ executable (gcc)? (including statically linked)

后端 未结 5 938
灰色年华
灰色年华 2021-01-30 17:29

I have a C++ application that I inherited, which consists of:

  • My main app
  • Several app-specific libraries (libapp1, libapp2, etc...)
  • Several \"thi
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 18:14

    As far as I know, not much information about static libraries is preserved when linking (since the linker just sees that library as a collection of *.o objects anyway).

    If you find the make command that links the final executable and add a -v flag, g++ will show you exactly how it calls the ld command. This should include all necessary static libraries, including libraries used by other libraries, or otherwise the link step would fail. But it might also include extra libraries that aren't actually used.

    Another possibly useful thing is that, at least on Linux, objects and executables usually store names of the source code files from which they were created. (Filename only, no path.) Try

    objdump -t executable | grep '*ABS*'
    

提交回复
热议问题