Hi experts, please help me solve this problem:

I compiled a program C++ by Linux gcc version 4 and the program can run perfectly in that computer. But when I run the program in another computer (Linux with gcc version 3. installed), it did not work and said:
"Floating point exception"

I am sure that the problem is about the difference between GCC versions (or maybe Linux version).

Can anyone tell me how to compile the program to run in the previous version? The program is very complex, and big, so I do not want to recompile it. I think there are solutions because the 2 machines using the same Linux GCC, just different version.

I am very aprreciate if you can help me.
Thanks in advance.
--Phuc

Why are you presuming that it's the compilers' fault, and not your code?

Your first time success is at best 90% skill and 10% luck.

> The program is very complex, and big, so I do not want to recompile it
Well that's what you'll have to do.

Why are you presuming that it's the compilers' fault, and not your code?
Your first time success is at best 90% skill and 10% luck.
The program is very complex, and big, so I do not want to recompile it
Well that's what you'll have to do.

I tried writing a simple program like this:

#include <stdio.h>
int main(){
    printf("abc\n");
}

and encountered the same problem. So, I am sure that is it not my code's false, just trust me in that.

Edited 3 Years Ago by pritaeas: Fixed formatting

Maybe the problem is because of different Linux? The machine in which I compiled the code is Linux Red Hat Enterprise 4., while the machine used to run the program is Linux RedHat Enterprise 3. If it is the case, any solution for that?

Thanks
--Phuc

Do you have a problem compiling code on both systems?

So it takes a few hours to build - what's the deal?
Just set the build going, and have a coffee / lunch / weekend depending how long it takes.

Ok I have to compile for "target" machines that I don't have access to now and again [The horrible world of the hetrogenious grid :( ].

The first thing is to ensure that you produce a 100% static link.
use gcc -static which will cause errors if you try to violate that. That solves most of the problem. BUT you are going to run into even more since you have to get it to run on an old machine.
gcc-4.0 is 3 years old, and you have to make sure that gcc is not putting anything special into your machine code. So you have to have a close look at the output from gcc -v to make sure that nothing unsupported has crept in (e.g. sse2 for example, which will not be supported on an old machine).

This article has been dead for over six months. Start a new discussion instead.