Running c code in terminal : "command not found" error

Discussion in 'Mac Programming' started by jakee.stoltz, Sep 17, 2010.

  1. macrumors newbie

    Joined:
    Sep 17, 2010
    #1
    I'm trying to run my .c file through terminal but keep running into the same problem. I use "gcc" and the file name but no matter what I try, it keeps giving me "-bash: gcc: command not found".

    Here is a screenshot.
    [​IMG]

    What am I doing wrong?

    Thanks
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Have you installed the Developer Tools (or gcc on it's own via other means)? OSX does not have gcc installed by default...
     
  3. thread starter macrumors newbie

    Joined:
    Sep 17, 2010
    #3
    I have a folder on my HD called Developer and it's full of stuff. I installed XCode quite a while ago so I don't remember for sure. How would I know for sure?
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    If you do /usr/bin/gcc what do you get. I get this:

    Code:
    Robert-Duncans-MacBook-Pro:~ robbie$ ls -l /usr/bin/gcc
    lrwxr-xr-x  1 root  wheel  7 15 Sep 21:11 /usr/bin/gcc -> gcc-4.2
    
     
  5. thread starter macrumors newbie

    Joined:
    Sep 17, 2010
    #5
    That's what I get. So apparently I don't have that installed.

    Do I just install gcc from the OS disc, sort of like installing XCode?
     
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Download and install the latest Developer Tools.
     
  7. thread starter macrumors newbie

    Joined:
    Sep 17, 2010
    #7
    Alright. Will do. I've updated to Snow Leopard since I installed XCode so I'm probably a version behind in that anyways.

    Thanks for the help.
     
  8. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    That's almost certainly what caused this. I don't think the developer tools survive .x upgrades (but the do survive .x.y).
     
  9. macrumors 6502a

    Joined:
    Oct 28, 2008
    #9
    As a matter of practice, I always wipe and install clean when doing .x releases. .x.y are different, but I've found that it is always better to have no cruft behind when doing major upgrades.
     
  10. thread starter macrumors newbie

    Joined:
    Sep 17, 2010

Share This Page