egcs-1.1.2 template explicit instantiation problems (Was: wstring ...)

Steinar Bang sb@metis.no
Fri Feb 11 02:21:00 GMT 2000


>>>>> Steinar Bang <sb@metis.no>:

> Today I was going to use wstring in the egcs 1.1.2 installation,
> that's the native gcc of SuSE linux 6.2,... and found that wstring was 
> commented out in <string>.
[snip!]
> However I also found this set of patches:
> 	http://www.cygnus.com/ml/egcs-patches/1999-Jan/0619.html
> and if they work I'm home free.

I ran into linking problems with these patches, which basically
reenables wchar_t stuff in the header files.

If I compile with -O2 and no debug, everything links fine.

If I compile with -g an no optimization I get linking problems for
symbols related to string_char_traits<wchar_t> (see the end of this
message), which I take that these functions hasn't been explicitly
instantiated anywhere.

Rebuilding the libstc++.so, involves extracting the source RPM from
the CD-ROM, hacking the source RPM, and preferrably building only the
libgpp RPM, which is a mess I'd rather avoid if I can.  It would
probably be better to get the newest gcc.

But I would rather use the native gcc (which is egcs-1.1.2) if I can,
so I have tried to do the explicit instantiation myself.
Unfortunately I still get the linking problems.

This is what I do:

#ifdef __GNUC__
wchar_t* string_char_traits<wchar_t>::move(wchar_t *, wchar_t const *, unsigned int);
wchar_t* string_char_traits<wchar_t>::copy(wchar_t *, wchar_t const *, unsigned int);
#endif

These are the flags I compile with:
g++ -c -pipe -DQT_NO_ASCII_CAST -Wall -W -g -fPIC -DQT_FATAL_ASSERT -I/home/sb/2x/include -I/home/sb/apps/qt/include -o .obj/debug/kutf8.o kutf8.cpp

These are the linker error messages I get:

.obj/debug/libwwwresolver.o: In function `qstrlen(char const *)':
/usr/include/g++/std/bastring.h(.basic_string<char, string_char_traits<char>, __default_alloc_template<1, 0> >::gnu.linkonce.t.c_str(void) const+0x17): undefined reference to `string_char_traits<char>::empty(void)'
/home/sb/2x/lib/libmetis_tools.so: undefined reference to `string_char_traits<wchar_t>::move(wchar_t *, wchar_t const *, unsigned int)'
/home/sb/2x/lib/libmetis_tools.so: undefined reference to `string_char_traits<wchar_t>::copy(wchar_t *, wchar_t const *, unsigned int)'
collect2: ld returned 1 exit status

Presumably there is something wrong with my explicit instantiation
syntax?  What does it mean when you add functions to an instanciation
of a templated stuct (as string_char_traits<wchar_t> is)?

All hints and tips appreciated!

Thanx!


- Steinar



More information about the Gcc mailing list