binary code incompatibility between Fedora and Linux.

I have run into the following issue:

I have simple program :
#include <iostream>
using namespace std;

int main()
cout << "Hello, World" << endl;
return 0;

After building on Fedora machines and copied to Debian, it failing with :

'Floating point exception'.

The same `program` being build on Debian, and being copied to Fedora machines
is working fine on all of them.

I'm wondering what is causing that, and what kind of flags may be added in order to achive binary compartibility - build on Fedora and run executables on any other Linux distributions.
please help me to find a solution to this as soon as possible..


If I remember right it is caused by incompatible shared libraries.

AFAIK the only way to guarantee binary compatability is to statically link everything. The other option is to cross-compile for the target.

You might want to try googling things like
floating point exception hello world
cross compiling

Good luck!
I guess this is why Linux programs are distributed as tarballs.
By cross-compiling you'd just be moving the problem from one place to another. It's best to just compile from source or use RPMs.
Yeh, the only thing guaranteed to be the same across linux distros is the kernel. The dynamic runtime libs that you don't usually see are the likely cause of your problem, with the different systems maybe having different versions. I've never tried statically linking them so I'm not sure how it would be done, maybe a linker switch. It may be the STL libs but the behaviour of these is quite tightly specified so it's less likely.

Run ldd against the executable on the Fedora box to see which libraries it is built against and then check for those libraries on the Debian box.

It's worth noting that Debian is notoriously slow for bringing out 'latest' releases, preferring to ensure stability. Whereas Fedora is a virtual test bed for the up to the minute latest Red Hat stuff. You may have better luck running on Ubuntu rather than Debian.
The problem that your having comes from a newer hash style used by modern fedora/redhat-based systems. You can make your programs compatible with older systems by passing the linker option...


For more information a simple Google search will turn up many results.

Happy Coding!
i have tried static linking but that will increase the size of the program too much....... i think i can solve it by loading Dynamically linked shared object libraries (.so) ( including .so files which must be wanted by my program will be created inside my folder )
>> Dynamically loaded and linked during execution using the dynamic linking loader system functions.

but do you know any g++ linker options(flags) so that my executable program during loading loads the .so files from my folder ,not from the default system library location "/usr/lib".....

so if u know the g++ flag for that please tell me....
When you run any program, the program looks for the dynaic library files it needs using the $LD_LIBRARY_PATH environment variable. Add the path to you libraries to this. The -L compile option has no effect when running the executable.
It seems to me that the two main (potential) problems have been identified.
Make sure to link with the old System V hash style as Saneticus recommends.

And, link to a specific (major) version of the library you want --one that is sufficiently old enough to be on both systems. You might want to take a read through the Linux Program Library HOWTO

Multiple versions of shared object libraries are often available on *nix systems; the ones listed with the plain-vanilla name are just hardlinks to the latest version (typically). You can query, load and use older versions though.

Good luck!
Last edited on
My intension is not to make it compatible with older versions....i want my program to use my shared object files without any problem.

currently.... my program during running searches Dynamically linked shared object libraries (.so) in /usr/lib only.....

i want my object code to search .so files in the location that i must prefer (in some folder like /home/mylib or in current directory).....

What must i do to make such object code????

is there any gcc linker options???????

That's fine. You shouldn't be having any problems with dlls you create yourself. If you take a moment to look through that link I gave you you will find how to have your program search for library files however you want.

Good luck!
Topic archived. No new replies allowed.