New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

GCC Problems!


Post Reply New Thread Subscribe

 
Thread Tools
Prthug996

 
Member Since: Sep 08, 2009
Posts: 5
Prthug996 is on a distinguished road

Prthug996 is offline
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
QUOTE Thanks
novicew

 
novicew's Avatar
 
Member Since: Jan 04, 2006
Location: Hamburg, Germany
Posts: 1,385
novicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to all
Mac Specs: MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)

novicew is offline
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
QUOTE Thanks
Prthug996

 
Member Since: Sep 08, 2009
Posts: 5
Prthug996 is on a distinguished road

Prthug996 is offline
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?
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,817
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
GCC - GNU Compiler Collection - Wikipedia, the free encyclopedia

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Prthug996

 
Member Since: Sep 08, 2009
Posts: 5
Prthug996 is on a distinguished road

Prthug996 is offline
Makes sense
QUOTE Thanks
Prthug996

 
Member Since: Sep 08, 2009
Posts: 5
Prthug996 is on a distinguished road

Prthug996 is offline
when i type ./MP0temp at the end it says no such directory or file
QUOTE Thanks
Prthug996

 
Member Since: Sep 08, 2009
Posts: 5
Prthug996 is on a distinguished road

Prthug996 is offline
Oops nvm. worked perfectly. THANK YOU. saved my ***
QUOTE Thanks
novicew

 
novicew's Avatar
 
Member Since: Jan 04, 2006
Location: Hamburg, Germany
Posts: 1,385
novicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to all
Mac Specs: MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)

novicew is offline
would you mind sharing the code you are trying to compile?
QUOTE Thanks
novicew

 
novicew's Avatar
 
Member Since: Jan 04, 2006
Location: Hamburg, Germany
Posts: 1,385
novicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to allnovicew is a name known to all
Mac Specs: MacBook Pro | iMac(2.1 G5) | MacBook(2.16 C2D) | MacMini (1.67 CD) | iPhone 4 | iPad (3rd Gen)

novicew is offline
glad it worked for you
QUOTE Thanks

Post Reply New Thread Subscribe


« How to install C / C++ compiler? | Perl script error »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
External Drives and copying Problems! woodyuk OS X - Operating System 3 05-22-2009 05:03 PM
Hello World app takes 45s to start from the terminal, gcc, gdb and dtrace problems Ethan asdf OS X - Development and Darwin 5 02-12-2009 05:03 PM
Realtek sound problems, lag problems Starflame Running Windows (or anything else) on your Mac 2 11-08-2008 10:54 AM
Help with gcc avalanche OS X - Development and Darwin 6 11-01-2008 11:00 PM
Problems (Sorry) Dominion Apple Notebooks 6 08-22-2006 11:09 PM

All times are GMT -4. The time now is 02:05 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?