Complete newbie needs gcc compiler help

From: James Bond (jbond_at_ue.com)
Date: 06/14/04


Date: Mon, 14 Jun 2004 09:17:37 -0400

I am a newbie to linux programming, and am trying to learn a little c++.
And much to my chagrin, I am having problems at the very beginning: I
can't get the compiler to work properly.

After perusing hundreds of useful online resources for c++ and linux
programming, I have discovered that nearly everything assumes you can
already use the compiler effectively. Reading the man page for gcc makes
it look easy, but I am stumbling somewhere.

Trying to write a simple hello world program,using a regular text editor,
I type this (comes from a Sam's book on c++ programming):

#include <iostream>

void Main()
{
cout << "Hello World.\n";
}

I save this to hello.cpp and then from the command line I type "g++ -o
hello hello.cpp"

I get the message the cout is undefined. It looks just like this:

[jb@localhost Source]$ g++ -o hello hello.cpp
hello.cpp: In function `void Main()':
hello.cpp:9: error: `cout' undeclared (first use this function)
hello.cpp:9: error: (Each undeclared identifier is reported only once
for each function it appears in.)
[jb@localhost Source]$
 

g++ -v tells me that I am using:
gcc version 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)

To me, that error implies that either cout is not defined in the iostream
library, yet my book, and several other sources, are quite clear that it
is. Otherwise, I assume I am doing something wrong with the compiler.
Finally, I guess that I might not have the proper libraries installed, but
if that is the case, I have been unable to determine just what I need.

Any help getting over this early hurdle is greatly appreciated. Thank you.

James



Relevant Pages

  • Complete newbie needs gcc compiler help
    ... I am a newbie to linux programming, and am trying to learn a little c++. ... can't get the compiler to work properly. ... I get the message the cout is undefined. ...
    (comp.os.linux.development.system)
  • C language now truly universal
    ... C language now truly universal ... a C compiler for z/VSE (an ... IBM mainframe operating system), and would like to ... Has a documented programming API. ...
    (comp.lang.c)
  • Re: [EGN] Numerical Accuracy
    ... The advice worked because in fact the Microsoft compiler had a bug. ... The capabilities of the optimizer are not so ... The language standard itself says ... of "programming" as a nonprofession. ...
    (comp.programming)
  • Re: why qwerty keyboard has NOT been used in ColorForth
    ... Forth minus source code and compiler and with a key table interpreter ... that could show dissasembled native opcodes and named Forth word ... The way Chuck put it, he wanted to explore the notion of reduced size ... It is what is known as bare metal programming. ...
    (comp.lang.forth)