Weirdness with PCH and <string>

Paolo Carlini pcarlini@unitus.it
Fri Dec 20 04:36:00 GMT 2002


Hi,

I have already reported about this on libstdc++ (and Benjamin
is already looking a bit into it), but perhaps it's worth a
repost on gcc, which seems more read overall...

Consider:

paolo:~> more header.h
#include <string>
#include <iostream>
paolo:~> g++ header.h
paolo:~> more test2.cc
#include "header.h"
int main()
{
  std::string str = "Paolo";
  //char* str = "Paolo";

  std::cout << str << '\n';
}
paolo:~> g++ test2.cc
/tmp/ccSZfk3p.o: In function `main':
/tmp/ccSZfk3p.o(.text+0x18): undefined reference to 
`std::allocator<char>::allocator[in-charge]()'
/tmp/ccSZfk3p.o(.text+0x32): undefined reference to 
`std::basic_string<char, std::char_traits<char>, std::allocator<char> 
 >::basic_string[in-charge](char const*, std::allocator<char> const&)'
/tmp/ccSZfk3p.o(.text+0x45): undefined reference to 
`std::allocator<char>::~allocator [in-charge]()'
/tmp/ccSZfk3p.o(.text+0x5e): undefined reference to 
`std::allocator<char>::~allocator [in-charge]()'
/tmp/ccSZfk3p.o(.text+0x71): undefined reference to 
`std::basic_ostream<char, std::char_traits<char> >& std::operator<< 
<char, std::char_traits<char>, std::allocator<char> 
 >(std::basic_ostream<char, std::char_traits<char> >&, 
std::basic_string<char, std::char_traits<char>, std::allocator<char> > 
const&)'
/tmp/ccSZfk3p.o(.text+0x94): undefined reference to 
`std::basic_string<char, std::char_traits<char>, std::allocator<char> 
 >::~basic_string [in-charge]()'
/tmp/ccSZfk3p.o(.text+0xad): undefined reference to 
`std::basic_string<char, std::char_traits<char>, std::allocator<char> 
 >::~basic_string [in-charge]()'
collect2: ld returned 1 exit status

???



More information about the Gcc mailing list