LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 03-02-2006, 09:41 PM   #1
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
Hiding Symbols in Static Libraries


Hi,

When I am writing static libraries, I try to minimize namespace pollution as much as possible by taking care not to export all sorts of silly little global symbols all over the place. But in some situations, there is no way to avoid having a symbol exported from a library, even though the symbols don't actually need to be used outside of the library (e.g. source code generated by other programs that I don't have much control over, or pre-compiled third-party libs).

Is there any way to have ar/ranlib -not- place certain symbols in the table of contents when I build the library? I have tried using objcopy to "filter" symbols out of the library but I could not get it to work like I wanted, the symbols still were being exported, according to nm.

If hiding the symbols completely is not an option, is there some way to alias the symbols to different names in the archive?

Thanks!
JC

Last edited by JCipriani; 03-02-2006 at 09:42 PM.
 
Old 03-03-2006, 02:08 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

As you already know, Windows .dll's and AIX shared libraries let you explicitly control which symbols are and are not publicly exported when you create a shared library. Linux, as far as I know, doesn't. So (again, AFAIK) you're pretty much stuck with using "static":

http://linuxgazette.net/issue55/tag/5.html
http://www.linux.com/howtos/Program-...ibraries.shtml

'Hope that helps .. PSM
 
Old 03-03-2006, 06:15 PM   #3
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Original Poster
Rep: Reputation: 15
Thanks for the links! The first one had the information I was looking for. I'll test it out more thoroughly later but "objcopy -L symbol_name" seems to do the trick (I had originally been playing with the "-N" option, not "-L").

Thanks again,
Jason
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Undefined references with static libraries Nightfox Programming 2 10-28-2005 07:43 PM
Making static symbols private/local in shared libraries skoona Programming 1 02-18-2005 04:14 PM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 05:54 AM
gaim trying to link static and shared libraries rose_bud4201 Linux - Software 0 09-28-2003 01:27 AM
Finding and Linking Static Libraries with gcc neorich Programming 15 08-10-2003 05:03 PM


All times are GMT -5. The time now is 12:10 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration