PDA

View Full Version : Xcode program won't run on any other mac besides mine




Jennygrrl
Mar 23, 2007, 07:51 AM
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:
#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);
}



MongoTheGeek
Mar 23, 2007, 07:55 AM
Is it being compiled development or release?

What error are you getting on the other systems?

Jennygrrl
Mar 23, 2007, 07:58 AM
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

lazydog
Mar 23, 2007, 08:29 AM
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

Jennygrrl
Mar 23, 2007, 08:55 AM
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
Mar 23, 2007, 10:00 AM
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
Mar 23, 2007, 10:02 AM
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