1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Running C programs on the terminal

Discussion in 'Mac Programming' started by s1587, Nov 17, 2007.

  1. macrumors newbie

    #1
    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.
     
  2. macrumors G4

    Eraserhead

    #2
    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.
     
  3. macrumors 6502

    rhoydotp

    #3
    screenshots please
     
  4. macrumors G4

    Eraserhead

    #4
    Good call, I was pretty confused myself ;).
     
  5. macrumors 68020

    pilotError

    #5
    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
     
  6. macrumors G4

    Eraserhead

    #6
    If you don't specify an output name its called a.out by default. So you use ./a.out to run it.
     
  7. macrumors newbie

    #7
    i have installed xcode as well. once i type gcc prog.c i get a message "-bash: gcc: command not found".
     
  8. macrumors 603

    Cromulent

    #8
    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.
     
  9. macrumors newbie

    #9
    Is there any specific path where the gcc folder must be stored for bash to recognize it?
     

Share This Page