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

Jennygrrl

macrumors newbie
Original poster
Feb 28, 2007
8
0
Hi everyone

I wrote a C++ program and compiled it in xcode. It runs, but only on my Mac. I think this might be because i have the xcode tools installed but my other Mac doesnt (They are both Intel macs).

Does anyone know how i can get my C++ program to work on another Mac without the dev tools? You can do this with Visual basic on Windows, so why not on a Mac?

thanks!
Jenny xx

P.S. If this makes any difference, here is my code:
Code:
#include <stdio.h>

int main()
{
	int num1, num2, num3;
	int sum;

	printf("Please enter the first number: ");
	scanf("%d%*c", &num1);   

	printf("Please enter the second number: ");
	scanf("%d%*c", &num2);
	
	printf("Please enter the third number: ");
	scanf("%d%*c", &num3);

	sum = num1 + num2 + num3;
	
	printf("The sum of the three numbers is: %d\n", sum);

	return(0);
}
 

Jennygrrl

macrumors newbie
Original poster
Feb 28, 2007
8
0
Is it being compiled development or release?

What error are you getting on the other systems?

It is being compiled as release.

When i open it up on another Mac, it just opens a blank Terminal window.
I have tried this on multiple Macs both Intel and PPC
 

Jennygrrl

macrumors newbie
Original poster
Feb 28, 2007
8
0
Hi

I was wondering how are you running your program? Have you tried running it from the command line in a terminal window?

b e n

Yes. I get Permission Denied on the 'other' Mac if i try that. And I get the same thing even if i type sudo. hmm :(
 

wittegijt

macrumors member
Feb 18, 2007
31
0
Eindhoven
You can try running otool -L appname in a terminal to see if you have linked extra libs. I think otool comes with Xcode however. If it is a simple console app (no external libs used) it should just return /usr/lib/libSystem.B.dylib

Wittegijt.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Ah okay, it sounds like after copying it you've lost the execution bit in the file permissions or you only the owner has execute permission (even though you may have the same username on both machines you may have a different user id. Depending how you copied the file you may not end up owning the file on the other machine). If you do a ls -l on the file I think all will become apparent!

Anyway, chmod a+x file-name should do the trick… perhaps using sudo if necessary.

Hope this helps!

b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.