This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problem linking with GCC 3.0 -- undefined reference to `std::codecvt<char, char, __mbstate_t>::id
>>>>> " " == Mark Martin <mmartin@integratedgenomics.com> writes:
[...]
>> The following problem has been preventing me from linking when
>> using streams in C++ code with GCC 3.0
>>
>> In function `std::basic_streambuf<char, std::char_traits<char>
>> >::overflow(int)':
>>
>> /usr/local/include/g++-v3/bits/std_streambuf.h(.gnu.linkonce.t._ZSt9use_fac
>> etISt7codecvtIcc11__mbstate_tEERKT_RKSt6locale+0xc): undefined
>> reference to `std::codecvt<char, char, __mbstate_t>::id'
[sorry if that appears twice, but it seems my previous message hasn't
made it upstream]
Hi,
I *had* exactly the same problem.
The problem is that the libstdc++ library included with gcc 3.0 was
compiled with an earlier version of GCC. GCC < 3.0 generates different
object code than gcc 3.0 in some circumstances, particularly with C++
code.
So, on my system (i686 RH7.1) gcc 2.95 produced the following symbols
in libstdc++:
$ nm --demangle /usr/local/lib/libstdc++.a | grep codecvt.*id
........ B std::codecvt<char, char, mbstate_t>::id
, whereas gcc 3.0 produced (from the bits/codecvt.h header file) and
expected the following:
$ nm --demangle main.o | grep codecvt.*id
........ U std::codecvt<char, char, __mbstate_t>::id
Which is not *exactly* the same - and difference turns the balance.
So, recompiling gcc 3.0 with itself cures the problem. I don't know
whether it's possible just to partly recompile e.g. the Standard C++
lib, but there could be also other parts not compliant with gcc 3.0
object code...
After the last weekend (when the compilation took place ;-) I got:
$ nm --demangle /usr/local/lib/libstdc++.a | grep codecvt.*id
........ B std::codecvt<char, char, __mbstate_t>::id
........ B std::codecvt<wchar_t, char, __mbstate_t>::id
Anyway,
happy (re)compiling
Claudio