Compile C

Discussion in 'Mac Programming' started by stevento, Feb 25, 2008.

  1. macrumors 6502

    stevento

    Joined:
    Dec 10, 2006
    Location:
    Los Angeles
    #1
    how do i compile C in terminal?
    gcc isn't a command
    help?
     
  2. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    Did you install XCode? If not, insert your OS X disc and install it.

    B
     
  3. thread starter macrumors 6502

    stevento

    Joined:
    Dec 10, 2006
    Location:
    Los Angeles
    #3
    thanks

    if i have a file called hello.c then i enter gcc hello.c to compile it but i dont know what to enter to run the program..?
    ./ is linux but i dont know what it is here
     
  4. macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #4
    If you simply compile with the command 'gcc hello.c' it will create a executable called 'a.out'. To run this enter this into terminal './a.out'

    To create a more meaningful name for the exec, use this:

    gcc hello.c -o hello (gcc <sourcefile.c> -o <desiredname>)
     
  5. thread starter macrumors 6502

    stevento

    Joined:
    Dec 10, 2006
    Location:
    Los Angeles

Share This Page