• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
C++ Compiling with OSX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ Compiling with OSX


  • Subject: C++ Compiling with OSX
  • From: Maurizio Martinelli <email@hidden>
  • Date: Wed, 14 Nov 2007 17:47:09 +0100

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

Maurizio
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list      (email@hidden)

This email sent to email@hidden

  • Follow-Ups:
    • Re: C++ Compiling with OSX
      • From: Maurizio Martinelli <email@hidden>
    • Re: C++ Compiling with OSX
      • From: Timothy Knox <email@hidden>
    • Re: C++ Compiling with OSX
      • From: "Andrew J. Hesford" <email@hidden>
    • Re: C++ Compiling with OSX
      • From: Jerry Fritschle <email@hidden>
    • Re: C++ Compiling with OSX
      • From: "Jack J. Woehr" <email@hidden>
    • Re: C++ Compiling with OSX
      • From: Bernard Giroux <email@hidden>
  • Prev by Date: Re: xterm and UTF-8
  • Next by Date: Re: xterm and UTF-8
  • Previous by thread: Re: Leopard X11 focus loss issue
  • Next by thread: Re: C++ Compiling with OSX
  • Index(es):
    • Date
    • Thread