Reputation: 12816
I have a pretty simple C program that does some cryptographic calculations using only standard library functions.
I will be running the program on Ubuntu (10.04, 32 bit) and compiled it on OS X 10.6 using cc with the -m32 flag. When I tried to run it on Ubuntu I got the error message "cannot execute binary file."
When I compile it on Ubuntu it runs fine.
Is there any easy way to compile code on OS X into a binary that will run on Ubuntu? If not, what are the differences that cause the binary to be incompatible?
Upvotes: 4
Views: 2133
Reputation: 966
You need to set up a cross compiler. Using the GNU toolchain, the process looks something like this:
I've never tried OSX as a host OS, so I don't know if there are any other complications, but this is the general approach. I'm working from memory, so add a comment if you need more help.
Upvotes: 4