GCC Problems!

Joined
Sep 8, 2009
Messages
5
Reaction score
0
Points
1
I'm a student completely new to C++ Programing, and my instructor knows nothing about Macs, so Im doing this on my own. I downloaded all of Xcode and wrote a program on it. Now Im trying to compile it. From what i can glean off the internet, I suppose to go to my terminal (which by the way, I didnt know existed, so you understand my knowledge level) and type something like;

gcc MP0temp.h

MP0temp.h being the program I wrote

Please Help!

PS Im very new to programing so the plainer the english the better

THANK YOU
 
Joined
Jan 4, 2006
Messages
1,385
Reaction score
146
Points
63
Location
Hamburg, Germany
Your Mac's Specs
MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
If it is a C++ file, you should save it with .cc extension. eg. hello.cc

To run your first C++, just follow the following steps.
1) Open a text editor and write your code.
Eg.
Code:
#include <iostream>                                                                                                 
  2 int main()
  3  {
  4   std::cout << "Hello World!" << std::endl;
  5   return 0;
  6 }

Save it as <file>.cc Eg. hello.cc in your Desktop.

2) Open Terminal.app from /Applications/Utilities/ and type
Code:
cd Desktop
and hit enter.

3) To compile the file
g++ <file>.cc -o <file> eg.
Code:
g++ hello.cc -o hello
If your program is correct, this will create an executable file.

4) To execute the program
./<file> eg.
Code:
./hello
 
OP
P
Joined
Sep 8, 2009
Messages
5
Reaction score
0
Points
1
Ok, cool thanks Im ganna give that a try later. But whats all this talk about GCC. And will your way alert me to my errors?
 
Joined
Jan 4, 2006
Messages
1,385
Reaction score
146
Points
63
Location
Hamburg, Germany
Your Mac's Specs
MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
would you mind sharing the code you are trying to compile?
 
Joined
Jan 4, 2006
Messages
1,385
Reaction score
146
Points
63
Location
Hamburg, Germany
Your Mac's Specs
MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)
glad it worked for you ;)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top