Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

o.0

macrumors newbie
Original poster
Sep 6, 2011
2
0
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?
 
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?

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.
 
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.
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.
 
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.

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.
 
For a basic C++ "Hello World" program you'd probably want to make sure the project is a Command Line Utility project too.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.