Quote:
Originally Posted by maha
I am using various static library ,so the size of executable is more.to reduce it i am hoping to know the .o files that are being used.so that i can include those files alone instead of the whole library.
|
A static library will not include "the whole library". The linker uses the static object library (the extension is .a) as an archive of object modules (the .o files), and extract only the ones it needs to satisfy an external reference.
The only way to reduce the size of an executable beyond this is to use shared libraries (the extension is .so). This only reduces the size of the executable by combining related and/or common functions into a single library (such as libc.so) that many programs use. Example of other common libraries, but are not used by every program, are libm (the math library) and libX11 (the X11 shared library). Not all programs use these; for instance, the cp utility uses libc, but not the others. "cp" does use additional libraries, just not libm or libX11.
Static object libraries are created with the "ar" tool, which works very similar to "tar". both make archives, but the ar tool includes a symbol table of global symbols defined by each object module in the library. The "ar" utility, like tar, can add or remove modules from the library. For details, see the manpage on "ar".