C++ in Xcode 4.1

Discussion in 'Mac Programming' started by o.0, Sep 6, 2011.

  1. o.0 macrumors newbie

    Sep 6, 2011
    So I'm starting a C++ class next week in college and I decided today to have a go at writing a simple program in Xcode (Just a Hello, World! one).
    I went to "new file" in Xcode and chose C++ syntax highlighting and wrote it..

    Now, I think it needs to be complied before it will run, and I don't know how to do that. I've tried lots of different things and googled around for a good while and couldn't get any answers.

    So, what do I have to do to get this to run and/or compile?
  2. Hansr macrumors 6502a

    Apr 1, 2007
  3. Shawnpk macrumors 6502

    Jan 13, 2011
    Los Angeles, CA
  4. gnasher729 macrumors P6


    Nov 25, 2005
    I remember that was the first exercise in K & R "The C Language" :D

    Hint: You don't want a file. You want a project.
  5. o.0 thread starter macrumors newbie

    Sep 6, 2011
    Ah, project it is then :p, thanks

    I don't see why it can't just compile from a file type I created though, it's annoying. When I chose the project option in the menu above I can see the run/compile options but they're greyed out and I can't use any of them.
  6. gnasher729 macrumors P6


    Nov 25, 2005
    The way you use XCode (program consisting of a single source file) is not typical. Programs usually consist of anything from tens to thousands of source files, and projects often consist of many programs. Wanting to compile a single file is exceedingly rare when you are programming for a living.
  7. iHutch105 macrumors member

    Aug 8, 2011
    For a basic C++ "Hello World" program you'd probably want to make sure the project is a Command Line Utility project too.

Share This Page