Cant Compile

Discussion in 'Mac Programming' started by dieseltwitch, Jan 4, 2009.

  1. dieseltwitch macrumors regular

    Joined:
    Jan 24, 2008
    #1
    I learning to write C code but i cant compile from the Xcode Program (this is the one i got for the iPhone Dev Kit, not sure if that makes a difference) but after i write the small program "hello World" i go to compile and its grayed out. what gives? what did i do wrong?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Tell us, exactly, how you created your project. Note if you did not start with a new project then you can't compile from within XCode. Creating a new C file or whatever outside a project will not work...
     
  3. dieseltwitch thread starter macrumors regular

    Joined:
    Jan 24, 2008
    #3
    then thats my problem! i just started a new file not a project.

    2nd question what is the command for running the complier in the terminal on mac. i know it cl blablabla.c on windows but whats the mac =
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    gcc -o programname filename.c
     
  5. dieseltwitch thread starter macrumors regular

    Joined:
    Jan 24, 2008
    #5
    Ok so i tried gcc -0 hello hello.c
    and it makes a second file with no ext. what ext do i use to for the out put file? In windows it makes a exe file what does it make in the mac os?
     
  6. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #6
    Mac OS executables actually don't have any extension at all.
     
  7. dieseltwitch thread starter macrumors regular

    Joined:
    Jan 24, 2008
    #7
    then how do i run it from the cmd line? when i type hello (the name of the output file it just faults out "-bash .........."
     
  8. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #8
    ./hello
     
  9. dieseltwitch thread starter macrumors regular

    Joined:
    Jan 24, 2008
    #9
    thank you much! sorry for sounding like such a newbie! gota start some where
     
  10. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #10
    It is not -0 (zero) it is -o (small letter o). There is no need for an extension for Mac OS X executables.
     

Share This Page