Linking an entire static library

I have an application which loads plugins (dynamic libs). The app and the plugins make use of a set of handy functions that I've compiled into a static library. I want to link the static library into the application, otherwise I'd just get a lot of copies everywhere.

The problem is that "cc" doesn't link entire static libraries, only the symbols referred to by the application. This is mostly a good thing, but this time I want the entire library since plugins may use any symbols.

Is it possible to tell "cc" directly or will I have to switch to some other method? The static library can not be made a part of the application (let's say I got several applications that use the same plugins).

[717 byte] By [coelurusa] at [2007-11-27 11:16:02]
# 1

You didn't tell us whether you want this in Linux or Solaris.

The Linux linker has the option --whole-archive to achieve this, on Solaris -z allextract does the same.

But if you want these symbols in multiple applications/plugins, why don't you put them into a _shared_ library and make either the applications or the plugins link to them? I would consider this much smarter than having a copy of these symbols in each and every application.

rschielea at 2007-7-29 14:16:45 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Thanks for both answers, I'll eventually need both of them.

The reason I wanted a static lib was probably because the number of plugins is rather large and I'd like to minimize the external dependencies. Quite a weak argument when I think about it, I guess I'll settle for a loadtime shared library. Thanks for that one too!

coelurusa at 2007-7-29 14:16:45 > top of Java-index,Development Tools,Solaris and Linux Development Tools...