Operating System - Tru64 Unix
1752512 Members
4722 Online
108788 Solutions
New Discussion юеВ

Re: Template instantiation with gcc 3.3.3 - multiple definitions

 
Sheila Balke
New Member

Template instantiation with gcc 3.3.3 - multiple definitions

Running on OSF1 V5.1B Tru64 Unix. Using gcc 3.3.3 compiler to build objects. Using the ar -rcv command to generate an archive file. The ar command spews out 100's of warning messages, "ar: Warning: ignoring second definition of xxxxx in archive" for variables associated with template instantiations. This did not happen with previous release of gcc and OSF.

The GCC Manual (http://gcu.gnu.org/onlinedocs/gcc-3.3.3/gcc/Template-Instantiation.html) talks about 3 options for Template Instantiation. Our problem with multiple definitions probably has to do with taking the third option, "Do Nothing".

Does anyone have a feel for option one (using compiler option -frepo and collect2) or option two (using compiler option -fno-implicit-templates)?

Any insight on templates would be appreciated.

Thank you.
2 REPLIES 2
Sheila Balke
New Member

Re: Template instantiation with gcc 3.3.3 - multiple definitions

Further clarification of problem:

Whenever two object modules that include the same STL header (ie, fstream) are archived using the ar utility, multiple defines for assorted symbols are added to the symbol table in the archive. This causes the archive utility to issue a warning message for each multiple symbol.

Using the -frepo compiler option eliminated only about half of the duplicate symbols. Then the collect2 linker wrapper spewed out undefined symbol messages as part of its processing.

Has anyone been successful in using the new g++ with STL code, without drowning in a torrent of warning messages?

Since we can't change the STL headers, what other options do we have to handle STL instantiations?

I'm assuming that pre-compiled headers (mentioned by Josuttis) are not an option with g++?

Thanks again.
Submitted by the originator.
Stephen Gross
New Member

Re: Template instantiation with gcc 3.3.3 - multiple definitions

Did you ever figure this one out? I'm having a similar problem, though not with templates. The problem really is that the inline functions don't get inlined and instead are preserved as symbolic names in each object file. Then, when you try to archive them together, you get multiple definition warnings. Supposedly, you can use -finline-size=n to increase the allowable size of an inlined function, but I had little luck with the option. Ideas?

Thanks,
--Steve (mrstephengross@hotmail.com)