gcc compiled executable not working across x86_64 linux platforms

Hi
I compiled a hello world program on two different 64-bit Linux machines, named quimby and node0331. When I compile on quimby and run on node0331 I get a "Floating exception (core dumped)" error. But if I do it in reverse, things work fine.

Here's my compilation on quimby:

$ uname -a
Linux quimby 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:28 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

$ cat hello.c
#include <stdio.h>
int main()
{
printf("Hello World\n");

return 0;
}

$ gcc -c hello.c -o hello.o ;
$ gcc -o hello hello.o
$ ./hello
Hello World

The I go to node0331 and run there:

$ uname -a
Linux node0331 2.6.9-42.0.3.ELsmp #1 SMP Fri Oct 6 06:28:26 CDT 2006 x86_64 x86_64 x86_64 GNU/Linux

$ ./hello
Floating exception (core dumped)

But again if I do this in reverse, things work fine. Has anyone ever experienced this problem.

Thanks in advance,

Sam

Yes, this can happen. Depends on your OS and compiler versions. Generally executing a program on an earlier version of an OS than the version upon which the program was compiled, as is the case with your example, is not formally supported. It may or may not work.

Ah, thanks for that feedback.

I guess there's nothing that can be done about that right? no gcc options which create generally compatible instructions (if there is such a thing)?

In any case, thanks for sharing your experience.

Sam

You could see if linking it statically would help (or equivalently making sure you have the same libraries on both systems -- ldd hello tells you which libraries exactly).