RE: Hide/export symbols in static library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eljay,

Thanks for your reply. Actually what I want to do is to
create an archive library (.a) with only few global symbols
exposed (or exported) and all other global symbols being
hidden. 

I cannot use "static" directive in "C" files as
my functions are used across files. 

If I archive several .o files using ar, all the global 
symbols remain exposed . So, I tried to do "partial linking" 
of the .o files using ld as I am not aware of any other
method of hiding global symbols in a static library. 

Thanks and regards,
Jyotirmoy



-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@xxxxxxxxx]
Sent: Tuesday, May 31, 2005 5:31 PM
To: Jyotirmoy Sharma; gcc-help@xxxxxxxxxxx
Subject: Re: Hide/export symbols in static library


Hi Jyotirmoy,

I not sure what you are trying to do.  It appears to me that you are using ld to create an executable called "lib.a", which is not an archive library (.a).  Since the -r (also -i or --relocatable) creates an OMAGIC file that can be consumed by ld, maybe it serves a similar purpose.

I think you should use the ar command to create an archive library (.a).

As I understand it, the ld command consumes archive libraries (.a), as well as shared object libraries (.so) and object files (.o), to produce executables (no extension, chmod a+x) or shared object libraries (.so).

Whether or not a symbol has external linkage depends outside the translation unit depends on whether or not you've specified that the translation scope identifier is static or not (in C and C++).

NOTE (as I understand it):  C++ anonymous namespace does not mean the identifier is internally linked only.  Still need to specific static.  Unfortunately?  Perhaps.

Using ld to create a shared object library (.so) in ELF format, you can use a --version-script=FILE command.

Using ld to create a shared object library (.DLL) in i386 PE format, there are several ld flags available to control symbol exposure.

HTH,
--Eljay




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux