Subject: Re: help for template woes with g++
From: [email-masked] (Mumit Khan)

3 Dec 1997 23:45:34 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: "John F. Kolen" <[email-masked]>
Cc: [email-masked]

> Those of you who are struggling with linker errors caused by templates (such
> as those found in STL) might like to know that -frepo works much better when
> combined with -O3.  It turns out that repo stumbles on inlined methods declared
> outside the class.  The -O3 forces the compiler to generate inline code,
> otherwise the compiler _decides_ what to inline and to generate.  See g++ info
> page for more details.
> 

Yes, this is a well-known problem. I believe I did document a few of these
cases a few years in my STL Newbie Guide (now hopelessly outdated). -frepo
has had problems as well, most of which have been fixed in egcs.

fwiw, with egcs-1.0 (and fsf 2.8 when released), this problem goes away,
at least on ELF and PE-COFF (i386). You can just let the compiler
instantiate all the templates it needs, and the linker will throw away the
duplicates.  Basically, the template instances go in named sections with
".linkonce"  attribute, and then linker does the rest. 

Sometime this weekend, I should have egcs-1.0 distribution for gnu-win32.

Regards,
Mumit -- [email-masked]
http://www.xraylith.wisc.edu/~khan/

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".