How NOT to compile a C++ program

posted in |
Submitted by varun on Fri, 26/08/2005 - 5:16pm.

You know you have been away from C++ programming (almost a year for me now) when you try to compile a C++ program like this:

varun@dumbledore:~/cpp$ gcc -ansi -pedantic hello_world.cpp
/tmp/ccNWmUfg.o(.text+0x1b): In function `main':
: undefined reference to `std::cout'
/tmp/ccNWmUfg.o(.text+0x20): 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/ccNWmUfg.o(.text+0x49): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccNWmUfg.o(.text+0x7a): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccNWmUfg.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'

Yikes!! What I uttered when I realized my mistake simply cannot be published here :-)

Trackback URL:
http://www.thoughtfulchaos.com/trackback/499

3 comments

I'mno Programmer, what was

Submitted by Savage Beast (not verified) on Fri, 26/08/2005 - 8:19pm.

I'm no Programmer, what was wrong with it? Are you supposed to use g++ instead of gcc?

Exactly

Submitted by varun on Fri, 26/08/2005 - 8:27pm.

You are right. g++ should be used and NOT gcc. I banged my head over this for about 10 minutes before I realized the stupidity I was indulging in.

For sometime I thought that my compiler was screwed and thats why it was spitting out all that garbage...

Sheeeesh....

Nice website !

Submitted by Anonymous (not verified) on Sat, 27/08/2005 - 10:19pm.

Nice website man ! Keep up the good work!