This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: using templates in shared library
> > Well, the first library is just required to contain the symbols
> > associated to my templates. If a new version doesn't have them, it's
> > not a new version but a broken version.
>
> The linker coulnd't know that :-)
It can. Maybe I'm not explaining things very well. Say I have a
library with all code/symbols for
vector<int>
Now I make a program main.cc,
main()
{
vector<int> foo;
}
and link it to the library. Obviously, since the library already
exists, it is possible to see that 'vector<int>' is present in the
library. I therefore want the 'main.o' or 'a.out' NOT to include the
'vector<int>' instance. It will only make it bigger if the symbols
were included, since the library is going to override the weak symbols
anyway.
> You can always use -fno-implicit-templates or -frepo, together with
> explicit template instantiation, to control where templates should
> go.
I know, but I like the automatic instantiation. The linker can look
into the shared library and see which symbols are there. I _only_ want
to discard those in my new object file, all the others should go in!
If I have a few zillion other templates in main.cc it's a pain having
to instantiate all them explicitly by hand.
Kasper