Reputation: 607
I created a test app in C as follows:
#include<stdio.h>
int main(void){
printf("Hello World!\n");
return 0;
}
I compile via the following command on my MacBook Air, running OS X Yosemite:
$ cc foo.c -o foo
I then upload the "foo" binary to my CentOS VPS, CHMOD 755, then attempt to execute via the following command:
$ ./foo
This returns the following result:
-bash: ./foo: cannot execute binary file
I also attempted to compile with -m32 in case it was a 64/32 bit conflict. The same result was produced.
Why will CentOS will not execute the binary?
Upvotes: 0
Views: 3209
Reputation: 249133
You built an executable on Mac OS X, and tried to run it on Linux. This will never work, because these two operating systems are not compatible. The easiest way to fix this will be to build your program on a Linux machine, perhaps a virtual machine running on your Mac. In general, the phrase describing this situation is "cross compilation."
Upvotes: 4