Re: C++ Compiling with OSX
Re: C++ Compiling with OSX
- Subject: Re: C++ Compiling with OSX
- From: "Andrew J. Hesford" <email@hidden>
- Date: Wed, 14 Nov 2007 11:04:01 -0600
Use g++ instead of gcc. You may also need to insert "using namespace
std;" after the include line.
On Nov 14, 2007, at 10:47 AM, Maurizio Martinelli wrote:
Hi all,
I am sorry to ask a question probably simple, but I can't solve this
problem.
I am new with C++ and I tried to run the first simple program to get
started.
The program is "Hello World":
#include <iostream.h>
// This program prints "Hello, World."
main()
{
cout << "Hello, World.\n";
return 0;
}
I called it primo.c, then I tried to run it:
$ gcc primo.c
primo.c:1:22: error: iostream.h: No such file or directory
primo.c: In function 'main':
primo.c:5: error: 'cout' undeclared (first use in this function)
primo.c:5: error: (Each undeclared identifier is reported only once
primo.c:5: error: for each function it appears in.)
I then tried to link the library iostream.h:
$ gcc -Wall -I/usr/include/gcc/darwin/3.3/c++/backward primo.c
In file included from primo.c:1:
/usr/include/gcc/darwin/3.3/c++/backward/iostream.h:32:20: error:
iostream: No such file or directory
In file included from primo.c:1:
/usr/include/gcc/darwin/3.3/c++/backward/iostream.h:34: error: parse
error before 'std'
primo.c:4: warning: return type defaults to 'int'
primo.c: In function 'main':
primo.c:5: error: 'cout' undeclared (first use in this function)
primo.c:5: error: (Each undeclared identifier is reported only once
primo.c:5: error: for each function it appears in.)
In the second output line, the compiler seems to tell me that it
cannot find iostream.h, but if i execute the ls command iostream.h
is there:
$ ls /usr/include/gcc/darwin/3.3/c++/backward/iostream.h
/usr/include/gcc/darwin/3.3/c++/backward/iostream.h
I also tried to run primo.c with iostream.h in the same directory
but it gave me the same output of `$ gcc primo.c'
I know that this is not exactly a X11 problem, but I hope you can
help me too.
I work on a iBook 12'' PPC G4 1.33GHz, Tiger 10.4.10. I have
installed XCode 2.4.1.
Bye
--
Andrew J. Hesford <email@hidden>
Department of Electrical and Computer Engineering
University of Illinois at Urbana-Champaign
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden