Mail Archives: djgpp/2000/06/05/04:30:36
>From: Scott Smith <skahfee AT mail DOT com>
>Reply-To: djgpp AT delorie DOT com
>To: djgpp AT delorie DOT com
>Subject: Help!
>Date: Mon, 5 Jun 2000 03:44:21 -0400 (EDT)
>
>Guys--
>
>I am completely stumped.. I am brand-new to c++, trying to teach myself in
>an effort to see if programming is a possible career for me. I'm sort of
>discouraged now.. I can't get past the first (and simplest) program in the
>book! Here is my code:
>
>#include <iostream.h>
>
>main()
>{
>cout << "Hello everyone...this is easy ";
>return(0);
>}
>
>Simple, right? So, I use this command to try to compile my work:
>
>gcc test.c
>
>And this is the contents of the error log file:
[SNIP]
>All I can say is "Oh my God"...What is going on? I consider myself to be
>very computer literate, and this has me completely stumped. I can't even
>imagine what I did wrong. Thanks in advance for any help!
Oh my God indeed. Hmmm, why not change your filename to:
test.cc
^^
++---- cc here instead of c
and then do a:
gxx -o test.exe test.cc
--or--
gcc -o test.exe test.cc -lstdcxx
The difference? `gcc' or `gxx' treats filenames differently based on the
filename extension. Filenames with `c' extensions are assumed by `gxx' or
`gcc' (and every C programmer) to be C programs. Where as filenames
with `cc' extensions are assumed by `gxx' or `gcc' to be C++ programs.
'gxx' and `gcc' differ in the way they link your program. `gxx' links
your progam with libstdcxx.a (the C++ standard library) by default, `gcc'
does not. Hence, you need to add -lstdcxx switch when you compile a C++
program using `gcc'.
Have fun...
----------------
_nimrod_a_abing_
------------------------------------------
Homepage: http://www.geocities.com/n_abing
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
- Raw text -