954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to create a Linux distro independent code

Hi..
I have created a shared object by developing and compiling it on RHEL 5.
Than I tried to use same shared object on RHEL 4 and SuSe 10.0.But it didn t work.Error message shown was " Floating point exception". Machine architecture was same for all the three distos.
So I want to know is it possible to compile a code in such a way that if it is compiled on RHEL 5 machine, same compiled code should work on any other Linux distros? If yes than how?

Thanx in Advance...

varsha0702
Newbie Poster
18 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

it should work on all distros. Most likely due to bad programming.

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 
it should work on all distros. Most likely due to bad programming.

Its a sample code downloaded from Intel site. Which I have compiled to shared object.

varsha0702
Newbie Poster
18 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

Tell me which language the code is written in, and I'll move it to the appropriate forum. Lounges aren't meant for support questions, and you'll receive better help if it's in the Software Development forums.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 
Tell me which language the code is written in, and I'll move it to the appropriate forum. Lounges aren't meant for support questions, and you'll receive better help if it's in the Software Development forums.

Its written in C++.

varsha0702
Newbie Poster
18 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

Moved.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

so why not telling us how to get that example code from INTEL side?

tesuji
Master Poster
721 posts since Apr 2008
Reputation Points: 158
Solved Threads: 98
 

> So I want to know is it possible to compile a code in such a way that if it is compiled
> on RHEL 5 machine, same compiled code should work on any other Linux distros?
the problem is caused by changes in the ELF binary format between RHEL4/FC5 and RHEL5/FC6 or later. (the hash section and the hash format for symbol resolution has changed).
while RHEL5/FC6 and newer can handle both types of hash format, only the classical 'sysv' format is supported by older versions.
to make elf binaries which are backward compatible, use the linker switch --hash-style=sysv

for example while compiling with g++, use -Wl,--hash-style=sysv

vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You