Instantiating templates in a shared library
Jon Brumfitt
jbrumfit@astro.estec.esa.nl
Tue Mar 16 09:20:00 GMT 1999
The template instantiation approach, used in egcs-1.1.1, appears
to work well. However, I have a problem trying to use templates
within a shared library - the templates get instantiated in each
executable that uses the library, which rather defeats my purpose
in using a shared library.
The only classes which are relevant to users of the library are
NON-template derived classes, such as:
class Foo : public Bar<int> {};
However, the client program has to include the header file, which
defines Foo. This results in the template class Bar<int> being
instantiated in the program.
I have tried explicitly instantiating the template in the shared
library. This does not actually help, because there is also a copy
instantiated in the executable.
I should welcome any ideas on how to solve this problem.
Thanks
Jon
More information about the Gcc
mailing list