3

I'm building a shared library that contains a public interface found some object file public.o

The shared library is composed of 100+ other objects files and I want to minimize the size if the .so file. Is there a way to remove of all the symbols from from the shared library that are not referenced by public.o? Alternatively, is there a way to retain only dependencies of extern "C" functions, stripping all of the unused C++ names?

user48956
  • 13,091
  • 17
  • 83
  • 137

2 Answers2

2

Look at this manual:
http://gcc.gnu.org/wiki/Visibility
it explains for example how to handle C++ names stuff.

fghj
  • 8,185
  • 3
  • 25
  • 52
1

You might use a recent GCC (e.g. a 4.6.1 version) and pass -flto at compile and at (library) link time.

(added) You could also play with the visibility attribute.

But I won't bother about the size of an *.so

Basile Starynkevitch
  • 216,767
  • 17
  • 275
  • 509
  • 4
    Stripping the unused symbols reduces our library size from 15Mb to 300kb. Its for an embedded Linux device - this is quite a saving. – user48956 Dec 19 '11 at 19:06