From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Buck To: greened@eecs.umich.edu Cc: jbuck@synopsys.com, egcs@cygnus.com Subject: Re: Template Instantiation Date: Mon, 09 Feb 1998 11:54:00 -0000 Message-id: <199802091728.JAA10214@atrus.synopsys.com> References: X-SW-Source: 1998-02/msg00369.html > > 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.