How does GCC compile applications that reference a static library

Posted by technobrat on Stack Overflow See other posts from Stack Overflow or by technobrat
Published on 2010-05-05T18:48:20Z Indexed on 2010/05/06 0:28 UTC
Read the original article Hit count: 677

Filed under:
|
|

I've read that the gcc compiler can perform certain optimization when compiling an application that references a static library, for instance - it will "pull" in only that code from the static library that the application depends upon. This helps keep the size of the application's executable to a minimum if portions of the static library are not being used by the app.

1) Is this true?

2) How does GCC know what code from the static library the application is actually using? Does it only look t the header files that are included (directly and indirectly) in the application and then pull code accordingly? Or does it actually look at what methods from the static library are being called?

© Stack Overflow or respective owner

Related posts about static

Related posts about library