a problem in c++ on red hat linux 9.0

Posted by: Linus Shen

a problem in c++ on red hat linux 9.0 - 06/15/06 01:42 AM

here's the programme,1.cpp:

Code:
 
#include<iostream> 
#include<string> 

int main() 
{ 
std::cout << "hello world" << std::endl; 
return(0);
} 
 
under the shell
$ gcc 1.cpp
and then appear too much unknown things~~

Code:
 
/tmp/ccL80Lex.o(.text+0x14): In function `main': 
: 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> >&)' 
/tmp/ccL80Lex.o(.text+0x21): In function `main': 
: undefined reference to `std::cout' 
/tmp/ccL80Lex.o(.text+0x26): In function `main': 
: 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*)' 
/tmp/ccL80Lex.o(.text+0x2f): In function `main': 
: 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> >&))' 
/tmp/ccL80Lex.o(.text+0x5c): In function `__static_initialization_and_destruction_0(int, int)': 
: undefined reference to `std::ios_base::Init::Init[in-charge]()' 
/tmp/ccL80Lex.o(.text+0x8b): In function `__tcf_0': 
: undefined reference to `std::ios_base::Init::~Init [in-charge]()' 
/tmp/ccL80Lex.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' 
collect2: ld returned 1 exit status 
HELP ME! THANKS!
Posted by: Linus Shen

Re: a problem in c++ on red hat linux 9.0 - 06/15/06 03:14 AM

o...somebody help me?...help~~~
Posted by: Gremelin

Re: a problem in c++ on red hat linux 9.0 - 06/15/06 02:49 PM

Try:
g++ 1.cpp -o 1
Posted by: Linus Shen

Re: a problem in c++ on red hat linux 9.0 - 06/16/06 02:51 AM

OH YEAH!! I GOT IT!!
I have loved you....
THANKS!
Posted by: Gremelin

Re: a problem in c++ on red hat linux 9.0 - 06/16/06 11:09 PM

No problems at all
Posted by: Scallion

Re: a problem in c++ on red hat linux 9.0 - 08/11/06 04:18 PM

instead of typing std:: everything, try a "using namespace std" after your # include's