Srini wrote:
bcc test.cpp
Huh?? I hope you meant gcc. And you have to use g++ to compile C++ -
not gcc.
Srini
Not technically true. You can do gcc test.cpp -lstdc++
But if you use g++, it will add the std c++ library for you.
--John Ratliff
------------------------------ test.cc ------------------------------
#include <iostream>
int main() {
std::cout << "Hello World!\n";
return 0;
}
---------------------------------------------------------------------
gcc is no good:
$ gcc test.cc
/tmp/cc3RNzo4.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/cc3RNzo4.o(.text+0x1e): 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/cc3RNzo4.o(.text+0x4a): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc3RNzo4.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc3RNzo4.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
but, this works just fine
$ gcc test.cc -lstdc++
Of course, since he didn't add that -lstdc++ line, it's would probably fail.