PDA

View Full Version : C++ in Xcode




s1587
Nov 18, 2007, 04:13 AM
Hi! I just downloaded Xcode 2.5 recently. The problem is i do not know how to execute simple C++ programs on it. I tried following the instructions that have been posted for similar queries on this forum but no luck getting the output.
When i click on "build and go". It gives me an error "no launchable executable present at path" . Can someone help me out. Thanks in advance.



kainjow
Nov 18, 2007, 10:06 AM
Start over from scratch. File > New Project > C++ Tool. Compile that template project, and if it works, add in your own code.

Sayer
Nov 18, 2007, 10:45 AM
Learn *how* to program before you attempt to actually program.

Krevnik
Nov 18, 2007, 12:58 PM
Learn *how* to program before you attempt to actually program.

That crossed a bit of a line... IDEs for someone just starting out tend to be confusing. Which is a problem. Hell, been on the platform since the OS 9 days and I still have problems figuring out which template means what every time Apple tweaks the terminology in the template names (which is pretty regularly).

s1587
Nov 19, 2007, 01:05 AM
I tried starting from the scratch as well. Still gives me the same error. Should i include some .obj or .exe extension for the file somewhere?

Krevnik
Nov 19, 2007, 02:00 AM
I tried starting from the scratch as well. Still gives me the same error. Should i include some .obj or .exe extension for the file somewhere?

Try creating the C++ tool from scratch, and then just running build and go without making any changes to the template... it should work.

As long as you aren't making changes to the project properties, it should continue to work (until you need to add new libs/etc) as you modify the code. If it still starts giving this error, my gut tells me there are other errors in the build log that are leading to the final executable not being built.

FearedBliss
Nov 25, 2007, 04:48 PM
Hey thanks, I was wondering how I did this. I also wipped out a simple switch code just to refresh my memory:

/* OS Questioneer 1.0.0
By Jonathan Vasquez
Made on 11/25/07
Last updated on 11/25/07
*/

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

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

cout << "What Operating System are you using ?" << endl;
cout << "1. Mac OS X" << endl;
cout << "2. Windows *" << endl;
cout << "3. Linux" << endl;
cout << "Current Selection: ";
cin >> switchOne;

switch( switchOne )
{
int switchTwo;

case 1:
cout << "You selected Mac OS X" << endl << endl;
cout << "What OS X version are you using ?" << endl;
cout << "1. 10" << endl;
cout << "2. 10.1" << endl;
cout << "3. 10.2" << endl;
cout << "4. 10.3" << endl;
cout << "5. 10.4" << endl;
cout << "6. 10.5" << endl;

cin >> switchTwo;

switch( switchTwo )
{

case 1:
cout << "You have selected version 10 - Too Old To Remember." << endl;
break;
case 2:
cout << "You have selected version 10.1 - Too Old To Remember." << endl;
break;
case 3:
cout << "You have selected version 10.2 - Puma" << endl;
break;
case 4:
cout << "You have selected version 10.3 - Panther" << endl;
break;
case 5:
cout << "You have selected version 10.4 - Tiger" << endl;
break;
case 6:
cout << "You have selected version 10.5 - Leopard" << endl;
break;
default:
cout << "You haven't selected a proper version, closing.";
break;

}

break;
case 2:

cout << "You selected Windows *" << endl << endl;
cout << "What Windows version are you using ?" << endl;
cout << "1. 1.0" << endl;
cout << "2. 3.0(1)" << endl;
cout << "3. 95"<< endl;
cout << "4. 98" << endl;
cout << "5. ME/2000" << endl;
cout << "6. XP" << endl;
cout << "7. VISTA" << endl;

cin >> switchTwo;

switch( switchTwo )
{

case 1:
cout << "You have selected 1.0." << endl;
break;
case 2:
cout << "You have selected 3.0(1)." << endl;
break;
case 3:
cout << "You have selected 95." << endl;
break;
case 4:
cout << "You have selected 98." << endl;
break;
case 5:
cout << "You have selected ME/2000." << endl;
break;
case 6:
cout << "You have selected XP." << endl;
break;
case 7:
cout << "You have selected VISTA." << endl;
break;
default:
cout << "You haven't selected a proper version, closing.";
break;
}

break;
case 3:

cout << "You have selected Linux" << endl << endl;
cout << "What distro of Linux are you using ?" << endl;
cout << "1. Debian or Deritive" << endl;
cout << "2. Red Hat or Deritive" << endl;
cout << "3. Slackware or Deritive" << endl;
cout << "4. Other" << endl;

cin >> switchTwo;

switch( switchTwo )
{

case 1:
cout << "You have selected Debian or Deritive." << endl;
break;
case 2:
cout << "You have selected Red Hat or Deritive." << endl;
break;
case 3:
cout << "You have selected Slackware or Deritive." << endl;
break;
case 4:
cout << "You have selected Other." << endl;
break;
default:
cout << "You haven't selected a proper distro, closing.";
break;
}

break;

default:
cout << "You have not selected anything, closing.";
break;
}

return 0;
}

s1587
Nov 29, 2007, 10:18 AM
I am still not able to execute the "Hello world" template. Could there be any problems with my downloaded version of Xcode?

Cromulent
Nov 29, 2007, 11:04 AM
#include <iostream>

int main (int argc, char * const argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}As long as the code looks the same as above then you should be fine.

What version of OS X are you running? Did you do anything special when you installed Xcode or was it a default install?

If you go to File Menu > New Project > Command Line Utility > C++ Tool and just click Build and Go does it still give you the error?

What files are actually in your project window?

s1587
Dec 6, 2007, 11:01 PM
Yes the code is very much the same. I am running on Leopard. I downloaded Xcode from the website. Any code i run it gives me the same error.

SamMiller0
Dec 7, 2007, 02:51 PM
Yes the code is very much the same. I am running on Leopard. I downloaded Xcode from the website. Any code i run it gives me the same error.

What website? Typically you install XCode from the Leopard DVD.

jerrywickey
Jun 16, 2010, 12:17 PM
If XCode comes up at all, the likelihood that there is sothing wrong with the download is negligible.

It sounds like you are concerned about the name of the executable. Don't change anything. Just only click this: Run > Console > Build and Go

You will see "Hello World" in your console screen shortly.

The actual executable, which is not .exe on a mac, is in your project folders. Nose around you will find the file that you can drop onto your desktop and execute. It will bring up the console screen for you when you run it. More complex and fun user interface screens are available with more programming effort

Jerry

Tex-Twil
Jun 16, 2010, 12:43 PM
If XCode comes up at all, the likelihood that there is sothing wrong with the download is negligible.

It sounds like you are concerned about the name of the executable. Don't change anything. Just only click this: Run > Console > Build and Go

You will see "Hello World" in your console screen shortly.

The actual executable, which is not .exe on a mac, is in your project folders. Nose around you will find the file that you can drop onto your desktop and execute. It will bring up the console screen for you when you run it. More complex and fun user interface screens are available with more programming effort

Jerry
Do you know that this is a 3 years old thread ?

pilotError
Jun 16, 2010, 07:06 PM
Do you know that this is a 3 years old thread ?

Would that make it a Dead Thread Fail? ;)