Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 17, 2007, 04:30 AM   #1
s1587
macrumors newbie
 
Join Date: Nov 2007
Running C programs on the terminal

Hi i am new to Mac so please help me out. I have to run a Linux shell using the terminal. My shell has been coded using C. I have gcc installed but bash refuses to recognize the command. I must run the program on the terminal only. Can someone please help me out here.
s1587 is offline   0 Reply With Quote
Old Nov 17, 2007, 05:21 AM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
So you load Terminal.app and type gcc and then it says 'command not found'?

If so you'll need to install the Developers Tools (Xcode) which is on the Mac OS X DVD or an up to date version can be downloaded from http://developer.apple.com/tools/download/ but you'll need a free developer account to do so.
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote
Old Nov 17, 2007, 07:14 AM   #3
rhoydotp
macrumors 6502
 
Join Date: Sep 2006
Quote:
Originally Posted by s1587 View Post
Hi i am new to Mac so please help me out. I have to run a Linux shell using the terminal. My shell has been coded using C. I have gcc installed but bash refuses to recognize the command. I must run the program on the terminal only. Can someone please help me out here.
screenshots please
rhoydotp is offline   0 Reply With Quote
Old Nov 17, 2007, 07:39 AM   #4
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Quote:
Originally Posted by rhoydotp View Post
screenshots please
Good call, I was pretty confused myself .
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote
Old Nov 17, 2007, 10:05 AM   #5
pilotError
macrumors 68020
 
pilotError's Avatar
 
Join Date: Apr 2006
Location: Long Island
So you wrote a program in "C"... did you compile it?

Sounds like you successfully started Terminal, if you have a .app,

./myApplication.app

should run it...

if you didn't compile yet,

gcc myApplication.c -o myApplication.app

then try and run it
pilotError is offline   0 Reply With Quote
Old Nov 17, 2007, 10:07 AM   #6
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
If you don't specify an output name its called a.out by default. So you use ./a.out to run it.
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote
Old Nov 17, 2007, 10:21 PM   #7
s1587
Thread Starter
macrumors newbie
 
Join Date: Nov 2007
i have installed xcode as well. once i type gcc prog.c i get a message "-bash: gcc: command not found".
s1587 is offline   0 Reply With Quote
Old Nov 18, 2007, 02:35 AM   #8
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by s1587 View Post
i have installed xcode as well. once i type gcc prog.c i get a message "-bash: gcc: command not found".
If you installed Xcode with the current Terminal session running you may just need to quit and relaunch the Terminal application for it to use the updated path information.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Nov 18, 2007, 04:02 AM   #9
s1587
Thread Starter
macrumors newbie
 
Join Date: Nov 2007
Is there any specific path where the gcc folder must be stored for bash to recognize it?
s1587 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Using Terminal to write programs, not allowing me to access the university's servers? smokeybear Mac Programming 4 Feb 2, 2013 12:32 AM
Running my C++ in Terminal... Contraversy Mac Programming 3 Nov 4, 2012 09:12 AM
Compiling and running C++ programs thrill4rishabh Mac Programming 30 Jul 29, 2012 05:19 PM
Compiling and running C++ programs thrill4rishabh Mac OS X 10.7 Lion 2 Jul 24, 2012 03:48 PM
Terminal command to open & close programs? yeeehaw Mac Programming 3 Jun 30, 2012 08:04 PM

Forum Jump

All times are GMT -5. The time now is 07:05 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC