GCC 4 + PCH + no inline template functions => undefined symbol ! ?

"Sébastien L." sleon@pointcarre.com
Fri Jul 1 10:29:00 GMT 2005


Hello,

I have a big problem with my application.
Everything works fine with GCC 3.4 (linux & Mac OS X) or Visual C++ 6 
(Win32).
I use templates. Most functions are inline but some are not.
I use precompiled header too because without it, compilation last 1 hour 
(15 minutes with it). In the pch, some template classes are included.

I tried to use GCC 4 on Linux and Mac but linking fail with ~2800 
undefined symbols. It seems most of them are not inline template functions.
I looked at "gcc.gnu.org/gcc-4.0/changes.html" but there is only stuff 
about friend + template. Nothing to help me there...

I have read following documentation "Using the GNU Compiler Collection", 
specially "6.6 Where's the Template?". No help there too...

Usually, I explicitly instantiate all the template I use in the units 
that define the templates themselves. I think the problem is associated 
with the use of the pch but I am not sure (because to check and 
recompile the application without the pch I have to fix a huge amount of 
code)
As I said, GCC 3.4 and visual C++ have no problem with that.

Is it a GCC 4 regression bug or am I wrong somewhere ?

Any idea ?

PS : gcc --version
gcc-4.0.0 (GCC) 4.0.0 (Mandrakelinux 10.2 4.0.0-0.2mdk)

Thank you for your help.

Sébastien L.



More information about the Gcc-help mailing list