iostream with gcc

Peter M Lee pml1@york.ac.uk
Thu Oct 25 09:14:00 GMT 2007


I apologize for what is probably a silly mistake on my part. I am just 
starting to use cygwin. When I tried a simple program

#include <iostream>
using namespace std;

/**
 * A simple program for demonstrating the basics of a C++ project.
 */

int main() {
    cout << "Hello, world";
    cout << endl;

  return 0;
}

with

$ gcc hello.cc

I got the following error message

/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0xd): 
undefined reference to `std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::size() const' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x60): 
undefined reference to `std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::operator[](unsigned int) const' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x9f): 
undefined reference to `std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::operator[](unsigned int) const' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0xce): 
undefined reference to `std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::operator[](unsigned int) const' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x135): 
undefined reference to `std::cout' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x13a): 
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& 
std::operator<< <std::char_traits<char> >(std::basic_ostream<char, 
std::char_traits<char> >&, char const*)' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x142): 
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& 
std::endl<char, std::char_traits<char> >(std::basic_ostream<char, 
std::char_traits<char> >&)' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x149): 
undefined reference to `std::cout' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x14e): 
undefined reference to `std::basic_ostream<char, std::char_traits<char> 
>::operator<<(std::basic_ostream<char, std::char_traits<char> >& 
(*)(std::basic_ostream<char, std::char_traits<char> >&))' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x177): 
undefined reference to `std::ios_base::Init::Init()' 
/cygdrive/c/Users/PB2579~1/AppData/Local/Temp/cc7nz7Xj.o:hello.cc:(.text+0x192): 
undefined reference to `std::ios_base::Init::~Init()' collect2: ld returned 
1 exit status

-- 
   00 O O o o...
  0     ____  _______________ ______________________ _________________
 ][_n_i_|( |_ |             | |  6 Arncliffe Mews  | |     pml1      |
(  _    | ||| | Peter M Lee | |    Alma Terrace    | |  @york.ac.uk  |
_||_|___|_|||_|_____________|_|___York__YO10_4EL___|_|+44_1904_654200|
  o   0--0      o    o    o      o-o          o-o       o    o    o
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list