Template Instantiation
Joe Buck
jbuck@synopsys.com
Mon Feb 9 11:54:00 GMT 1998
> > On both of these systems, it works pretty much like it does with Borland
> > C++. All needed templates are instantiated in each object file, but
> > weak symbols are used. At link time, one weak symbol is used as the
> > definition. If you have a recent GNU ld, the duplicate definitions, if
> > any, get stripped out and are not included in the binary. If you have
> > an older linker or are using the Solaris linker, everything works, but
> > your executable may contain extra copies of some functions.
>
> This just does not work at all:
>
> CXXFLAGS = -DDEBUG=0 -DLINUX_LIBC6 -pipe -frtti -Wno-reorder \
> -Wno-unused
>
> I get lots and lots of undefined symbols, all of them from
> templates.
I didn't state something because I assumed you knew it: the compiler
must see the definitions of your template functions, not just their
declarations. Definitions must be visible at the point of use. With
or without -frepo, the compiler and linker won't go looking in other
files for template definitions.
More information about the Gcc
mailing list