LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   to know the .o files that have been used from a static library. (https://www.linuxquestions.org/questions/linux-newbie-8/to-know-the-o-files-that-have-been-used-from-a-static-library-4175474271/)

maha 08-22-2013 07:27 AM

to know the .o files that have been used from a static library.
 
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.

pan64 08-22-2013 08:19 AM

Long time ago ident was used to help on this (see man page), but I think nowadays it is not in use any more. So I think there is no direct way, you need to check the .o files one by one (the command nm may help you).

Lantzvillian 08-22-2013 12:55 PM

OP Are you unable to access the source?

Valery Reznic 08-23-2013 12:49 AM

Quote:

Originally Posted by maha (Post 5013762)
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.

Linker pull into executable from the library only needed objects - not whole library, so specifying those files by hand will result in a lot of work with exactly same executable size

jpollard 08-23-2013 02:00 PM

Quote:

Originally Posted by maha (Post 5013762)
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".

maha 08-29-2013 08:17 AM

thankyou.now i got an idea and a way to approach this problem


All times are GMT -5. The time now is 04:12 AM.