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

s1587

macrumors newbie
Original poster
Nov 16, 2007
14
0
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

Moderator emeritus
Jun 15, 2000
7,958
7
Start over from scratch. File > New Project > C++ Tool. Compile that template project, and if it works, add in your own code.
 

Krevnik

macrumors 601
Sep 8, 2003
4,100
1,309
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

macrumors newbie
Original poster
Nov 16, 2007
14
0
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

macrumors 601
Sep 8, 2003
4,100
1,309
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

macrumors member
Nov 25, 2007
50
0
Hey thanks, I was wondering how I did this. I also wipped out a simple switch code just to refresh my memory:

Code:
/* 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

macrumors newbie
Original poster
Nov 16, 2007
14
0
I am still not able to execute the "Hello world" template. Could there be any problems with my downloaded version of Xcode?
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Code:
#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

macrumors newbie
Original poster
Nov 16, 2007
14
0
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.
 

jerrywickey

macrumors member
Apr 16, 2009
81
0
Key West
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

macrumors 68030
May 28, 2008
2,501
15
Berlin
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 ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.