Skip to content
Advertisement

Compiling C Program on OS X to Run on Linux

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?

Advertisement

Answer

I’m afraid you can’t given the minimum portability of gcc.

Of course you can build a cross compiler like this but I’ll suggest you to use and compile with an ubuntu virtual machine.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement