Running C programs on the terminal

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

  1. macrumors newbie

    Joined:
    Nov 16, 2007
    #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

    Joined:
    Nov 3, 2005
    Location:
    UK
    #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

    Joined:
    Sep 28, 2006
    #3
    screenshots please
     
  4. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    Good call, I was pretty confused myself ;).
     
  5. macrumors 68020

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #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

    Joined:
    Nov 3, 2005
    Location:
    UK
    #6
    If you don't specify an output name its called a.out by default. So you use ./a.out to run it.
     
  7. thread starter macrumors newbie

    Joined:
    Nov 16, 2007
    #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

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #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. thread starter macrumors newbie

    Joined:
    Nov 16, 2007
    #9
    Is there any specific path where the gcc folder must be stored for bash to recognize it?
     

Share This Page