LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2013, 07:27 AM   #1
maha
LQ Newbie
 
Registered: Jul 2013
Posts: 7
Blog Entries: 2

Rep: Reputation: Disabled
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.
 
Old 08-22-2013, 08:19 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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).
 
1 members found this post helpful.
Old 08-22-2013, 12:55 PM   #3
Lantzvillian
Member
 
Registered: Oct 2007
Location: BC, Canada
Distribution: Fedora, Debian
Posts: 210

Rep: Reputation: 41
OP Are you unable to access the source?
 
1 members found this post helpful.
Old 08-23-2013, 12:49 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by maha View Post
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
 
1 members found this post helpful.
Old 08-23-2013, 02:00 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by maha View Post
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".
 
1 members found this post helpful.
Old 08-29-2013, 08:17 AM   #6
maha
LQ Newbie
 
Registered: Jul 2013
Posts: 7

Original Poster
Blog Entries: 2

Rep: Reputation: Disabled
thankyou.now i got an idea and a way to approach this problem
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a static avr library and just include header files in code? saavedra29 Linux - Software 2 04-29-2013 11:17 AM
creating static library that includes another static library kskkumar Programming 2 10-22-2007 10:51 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration