2

I haven't used Xcode in awhile and overall new to macs. How od I run a C++ program from Xcode V5.02. I don't see a command line function anymore?

Trying_hard
  • 8,931
  • 29
  • 62
  • 85

3 Answers3

4

In Xcode, select File>New>Project. Then navigate to the Application tab under OS X. The last choice will be "Command Line Tool". Hit Next. Then, select C++ in the type pulldown menu at the bottom. Name your project, hit next, choose a place to save, and click Create. You will see a file called main.cpp. Select it, and you're ready to go!

John Farkerson
  • 2,543
  • 2
  • 23
  • 33
2

Xcode supports c++ in objective-c projects through .mm files, but not on its own.

UPDATE: Guess I was wrong, see here: http://neilmonday.blogspot.com/2008/02/how-to-compile-basic-c-programs-in.html and here: How do I create a new C++ project in XCode?

Run xcode-select --install to make sure you command line tools installed on the system.

Community
  • 1
  • 1
virindh
  • 3,775
  • 3
  • 24
  • 49
  • 3
    On the contrary, you can create and compile C++ and a .mm means Objective-C++ – uchuugaka Jan 29 '14 at 00:22
  • 2
    My Xcode has it, I believe the difference is that you dont have command line tools installed.Starting in mavericks, they have to be installed separately from Xcode. Type the following into Terminal: xcode-select --install then you should see it. – virindh Jan 29 '14 at 00:27
0

See this SO answer for help with command line tool installation.

Basically the terminal

command is

xcode-select --install

The other option is to create a C++ Command Line tolls project.

Community
  • 1
  • 1
zaph
  • 111,848
  • 21
  • 189
  • 228