PDA

View Full Version : Running C programs on the terminal




s1587
Nov 17, 2007, 04:30 AM
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.



Eraserhead
Nov 17, 2007, 05:21 AM
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.

rhoydotp
Nov 17, 2007, 07:14 AM
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

Eraserhead
Nov 17, 2007, 07:39 AM
screenshots please

Good call, I was pretty confused myself ;).

pilotError
Nov 17, 2007, 10:05 AM
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

Eraserhead
Nov 17, 2007, 10:07 AM
If you don't specify an output name its called a.out by default. So you use ./a.out to run it.

s1587
Nov 17, 2007, 10:21 PM
i have installed xcode as well. once i type gcc prog.c i get a message "-bash: gcc: command not found".

Cromulent
Nov 18, 2007, 02:35 AM
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.

s1587
Nov 18, 2007, 04:02 AM
Is there any specific path where the gcc folder must be stored for bash to recognize it?