This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: using templates in shared library
- To: K dot Peeters at damtp dot cam dot ac dot uk
- Subject: Re: using templates in shared library
- From: mrs at wrs dot com (Mike Stump)
- Date: Wed, 9 Dec 1998 11:43:11 -0800
- Cc: egcs at egcs dot cygnus dot com, oliva at dcc dot unicamp dot br
> From: Kasper Peeters <K.Peeters@damtp.cam.ac.uk>
> Date: Wed, 9 Dec 1998 19:27:39 +0000 (GMT)
I agree with your frustration... We need better docs for this stuff.
> Unless I misunderstood your procedure, this also doesn't work. Let
> me state my problem again: I am building _two_ shared libraries and
> _no_ executables. Library 1 uses vector<int> and so does library
> 2. When I build library 1, the default egcs options will result in
> vector<int> being instantiated in library 1. Good. Then I build
> library 2 and during the link phase, I tell it to link dynamically
> to library 1.
> It should be trivial for the linker to figure out that library 1
> already has vector<int>. I want it to drop the instantiation of
> vector<int> from library 2.
> The -frepo only seems to work if I have an executable too. I could
> make a trivial demo that uses everything in library 1 and 2, but that
> makes the compiler recompile the demo, not the library.
Assume we have the structure:
lib1: lib1a.cc lib1b.cc
lib2: lib2a.cc lib2b.cc lib1.so
app: app.cc lib1.so lib2.so
You:
gcc -frepo -c lib1a.cc
gcc -frepo -c lib1b.cc
-gcc -frepo -o delete_me lib1a.o lib1b.o
gcc -shared -o lib1.so lib1a.o lib1b.o
gcc -frepo -c lib2a.cc
gcc -frepo -c lib2b.cc
-gcc -frepo -o delete_me lib2a.o lib2b.o lib1.so
gcc -shared -o lib2.so lib2a.o lib2b.o
Now, you can try that or let us know if it doesn't work and why.
For the app, one can use default compile or if one wants, one can use
-frepo.
gcc -o app app.cc lib2.so lib1.so
or
gcc -frepo -c app.cc
gcc -frepo -o app app.o lib2.so lib1.so
I think this should work.