View Full Version : C++ to run on Apple MAc Computer

11-03-2011, 07:50 PM
Hello I am starting some lessons on C++
I use an Apple Computer
IMac desktop

I am new using Xcode for C++ (and also for the language C++ itselfs), but i want to try to build a working commandline executeable with Xcode.

My code works with DevC++ on windows, but i'm using a mac at home and would like to test my apps.

will someone explain how i make a project for use with Xcode?

Basically I want to be able to run my C++ program right from Xcode without having to go to Terminal

Right now the program is working from Terminal.
But when i go back to Xcode it does not work. I get message of "build failed"

As well Would i be ok to just type my C++ code in Text wrangler and then run it all in Terminal?

I still would rather have it all work in one simple run from Xcode. please tell me how to do that. thanks

Problem is last simple program I got to work on my old Windows computer
when i run it i got the 2nd window to pop up.

When I run it on my MAC using Xcode. When i run and build
i get message of "build succeeded" which is good
but no second screen of the program working

here is the actual code

Ok Now I got Xcode to work.

I am not able to get the separate screen to work when i run a simple program.

So here is my program just a Helloworld program

#include <iostream.h>

int main()

int mynumber;
mynumber = 34
cout << " my number is ";
cout << "Hello world!" << endl;
cout << mynumber;
return 0;


So when i run it in Xcode, it works. it says build Succeeded
however i am supposed to get a second pop screen like a command prompt, like same when i run program on my Windows computer
that has "hello world" and 34 etc.

What function on Xcode do i use to make this happen?

11-04-2011, 01:52 AM
Ok here is what i have done next. I follow some instructions online and was able to get c++ to work and compile from xcode
but it only works in a different format.

this is what I have put in it that works in Xcode

#include <stdio.h>

int main (int argc, const char * argv[])

// insert code here...
printf("this is my first project\n");

return 0;

And I get it to work. But how come it only works with the line as "printf"?
as the proper way to write that line is this

#include <stdio.h>

int main (int argc, const char * argv[])

// insert code here...
cout <<"this is my first project");

return 0;

So when i try to run it this way , it does not work and i get error in my lines.
but this format works in Windows using the Dev C++ etc.

So what can you say? do i have to change the formats for Apple?