LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-28-2010, 04:10 AM   #1
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Rep: Reputation: 1
Compiling a program both for Fedora and Ubuntu


Hi,

I'm sometimes compiling a piece of software on my Fedora 13 machine and then transferring it to an Ubuntu box. Recently I noticed this would yield issues with Fedora's .so files:

Given I had a program's binary and an .so file the program would attempt to load, both compiled on Fedora, the program would run fine on Ubuntu 8.04 LTS but would be unable to load to open the Fedora .so with an "ELF file OS ABI invalid" error.

Now any program I natively compile on Ubuntu which I run on Fedora instead, will throw the *same* error with Fedora .so's - so basically neither a Fedora bin on Ubuntu, nor an Ubuntu bin on Fedora can load the Fedora .so files, only a Fedora bin natively on Fedora can.

That means Fedora .so files are always a problem on Ubuntu, and Ubuntu bins are always a problem on Fedora (unable to load system libs there).

This is a bit odd for e.g. binary redistributions of programs (which are rare I know) and I also found out that e.g. Tibia's linux client suffers from this issue (throws "ELF file OS ABI invalid" on my Fedora 13 when attempting to load my system's libGl).

And I started to wonder whether the only way to work-around to get something that works on all platforms is a Fedora binary shipped with .so files compiled on Ubuntu - which seems a bit stupid and ridiculously complicated just to get something that works flawlessly everywhere. Isn't there e.g. a gcc switch that will allow me to compile the .so files on Fedora in such a way that they can also be used on an Ubuntu system so just compiling everything on Fedora, yet getting it to work on Ubuntu aswell would be possible?
 
Old 06-28-2010, 01:12 PM   #2
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 128Reputation: 128
Make it 100% static. Make sure you ship every libraries that are going to be used down to libC or ligGCC. Or compile your apps as a big binary blob that include all .so in it. It is possible, but I never tried, so I am of no help here.
 
Old 06-29-2010, 04:02 AM   #3
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
That solution is a bit inconvenient because the software I tested this with relies on .so loading for runtime modules.

Since .so files compiled on Ubuntu work, that gcc must be doing something different (e.g. using a specifically different version of some important lib or an older ELF format or whatever). I guess there must be a way to replicate this on Fedora? (E.g. by copying the lib there and explicitely linking it instead or using a gcc flag to use that other format) It is pretty tough to do this though given you have no idea what that actual difference is. But if anyone has even a slight idea what it could be, I'd really like to find out.
 
Old 06-29-2010, 06:09 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,628

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
Files created on Ubuntu 8.04 should usually work
on Fedora 13. I see no reason why not.

Files created on Fedora 13 will never work on Ubuntu 8.04.
Fedora 13 has glibc-2.12. Applications will depend on that.
"Static" is the only way. Ref. post #2.

( Ununtu 8.04 has glibc-2.7 ( = libc6 2.7 ))
.....
 
Old 06-30-2010, 07:46 AM   #5
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
I got the impression you haven't really read my post - although I have to admit it is quite long and it is easy to mix up things.

Quote:
Files created on Ubuntu 8.04 should usually work
on Fedora 13.
They do not when loading .so's of Fedora. See above

Quote:
Files created on Fedora 13 will never work on Ubuntu 8.04.
They do, but fail to load Fedora .so files there (but can load Ubuntu .so files! without issues).

Now I'm wondering why that is that way (there seems to be something special to the .so files compiled on Fedora) and how I can compile .so files that work everywhere and not only on Fedora for Fedora binaries (they don't work on Fedora for Ubuntu bins and also not on Ubuntu for Fedora bins, just on Fedora for Fedora bins!).

The Fedora binaries themselves don't cause problems on Ubuntu, but the .so files do. Therefore I'd like to know how those .so files differ and if I can compile .so files on Fedora that are like those on Ubuntu.

I don't know whether Ubuntu .so files work with better with Ubuntu bins on native Fedora though. But I assume they do, since Ubuntu bins refusing to load any .so files on a Fedora system no matter of what origin would be a bit strange (since it seems to be an ABI compatibility issue which hints that one ABI actually needs to work as it is the case on Ubuntu systems).

Last edited by mrJones; 06-30-2010 at 07:48 AM.
 
Old 07-01-2010, 02:59 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,628

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
Sorry, it appears that the Fedora 13 gcc has no glibc 2.12 content.
Mostly glibc 2.4 objects. Please see for yourself : readelf -s gcc.

So the most 'F 13' binaries will start on Ubuntu 8.04. And then they
will search for shared libraries with objects / symbols matching the
libs, that the binary was compiled with ? Example , please.

Shared libraries : Do not expect them to work. Depends on glibc 2.12 ?

And again : Usually standard applications from Ubuntu 8.04 should work
on Fedora 13. If they don't : May be investigate what is happening.
You may just have had some bad luck with your applications.
Show an example application, please.

An interchange of applications and libraries is probably not meant to
take place between Ubuntu 804 and Fedora 13 ( and vice versa ) :
Not a thing one will find much info about.

Creating libraries for Ubuntu 804 on Fedora 13 : I'd say it is impossible.
..

Last edited by knudfl; 07-01-2010 at 03:03 AM.
 
Old 07-01-2010, 06:25 AM   #7
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
One example of an application that fails to open .so files on Fedora is the official linux client of the MMORPG "Tibia" (free to register/play). It cannot open libGl due to an OS ABI problem. I cannot tell whether it has been compiled on Ubuntu obviously, but it's the same problem reversed when I try to run my Fedora files with their Fedora .so's on an Ubuntu box. Therefore I guess the Tibia client has been compiled with some older libc version which cannot deal with Fedora's newer .so files.

Quote:
Creating libraries for Ubuntu 804 on Fedora 13 : I'd say it is impossible.
That's sad I hoped there is some way to install an older glibc and make gcc use that one (given this is the source of those problems which I simply don't know (I never saw that OS ABI error before) and which was the original reason I created this thread). Especially that also Fedora programs (not only Ubuntu applications on Fedora) cannot open their own .so files from Fedora on an Ubuntu machine is odd.

That seems the most confusing thing to me, actually:
- Ubuntu binaries on Fedora seem to depend on themselves (Ubuntu) to load .so files and cannot load Fedora .so's
- Fedora binaries on Ubuntu seem to depend on the system they're running on (Ubuntu) to load .so files and cannot load Fedora .so's

Isn't that a bit strange? Maybe Tibia has actually another issue. Or given EITHER the binary compilation system or the host system is Ubuntu, a program can only load the older .so's. That would be pretty odd though.

Last edited by mrJones; 07-01-2010 at 06:28 AM.
 
Old 07-01-2010, 10:45 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,628

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
Quote:
.. Especially that also Fedora programs cannot open their
own .so files from Fedora on an Ubuntu machine is odd.
The " .so files from Fedora " were compiled with glibc-2.12
and as such not usable on a Linux with an older glibc.
..
 
Old 07-01-2010, 05:23 PM   #9
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
Hmm. And there is no known easy way to use an older glibc for compiling programs than the one shipped with Fedora?

Thanks for clearing that up though. A bit sad that glibc seemingly likes to break compatibility sometimes. I envy windows a bit for being more continuous here (or maybe also less innovative but meh, it just works).

EDIT: Oh. I just found this! Extremely interesting and helpful on this topic. It seems like it might actually allow me to compile .so files on Fedora 13 that also work on Ubuntu. I'll post to this thread given I actually get it to work in case someone else's interested in an actual use case for this situation.

Last edited by mrJones; 07-01-2010 at 05:26 PM.
 
Old 07-01-2010, 05:32 PM   #10
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
Ok. Using "readelf -V library" on both my Fedora bins and .so files, the output suggests it does NOT require anything newer than glibc 2.3 to run. Now Ubuntu is supposed to have that glibc version.

Is there possibly another thing which could cause this OS ABI error?
 
Old 07-02-2010, 02:36 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,628

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
Let me ask, how come you don't just compile do the compiling
on Ubuntu. That's the way it is usually done.
Like building a .deb package on Ubuntu.

All binaries for Ubuntu / Debian are build on on of those.
..
 
Old 07-02-2010, 08:39 AM   #12
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
Well, for the program to run on both systems, the binary needs to be compiled on Fedora and the .so files on Ubuntu. That's simply a bit annoying, also given that my Ubuntu system is just a server box that is unsuitable for compiling anything graphical since it doesn't have the necessary things installed. Also always transferring the source there for compilation is annoying. [it wouldn't be impossible and if there's no other solution I'd do it of course]

Since the .so files don't seem to require anything newer than glibc 2.3 I am now *very* curious why this OS ABI error happens. I'd really like to know what is causing this because so far, noone was able to tell me.
 
Old 07-02-2010, 04:22 PM   #13
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,628

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
May be 'ldd' can help to identify the issues :

ldd <file>.so.x.x.x

..
Why not install Ubuntu 8.04.x on a spare partition ?
Would make things much easier.
..
 
Old 08-02-2010, 12:36 PM   #14
mrJones
LQ Newbie
 
Registered: Jun 2010
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: 1
I found the cause of the issue now.

I compiled the main program with -fno-stack-protector but accidentially didn't submit that flag to the .so file itself due to a small mistake when using the GNU build system (autoconf and those).

Some hacker has examined the ubuntu-compiled .so file and the fedora-compiled one and was eventually able to spot that the fedora .so actually WAS depending on a newer glibc due to this missing flag although it wasn't supposed to. Recompiling it properly solved all issues.

Thanks for all your help and sorry I couldn't come across this earlier. I hope this thread helps others to find out that some GLIBC features in their program which haven't been deactivated at compile time and aren't present on the target platform are most likely the cause of this "ELF OS ABI invalid" error message (and therefore e.g. -fno-stack-protector might help as gcc flag).
 
1 members found this post helpful.
  


Reply

Tags
binary, elf, fedora, invalid, linux, ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing and compiling java program in fedora 12 kushwaha.naveen Linux - Newbie 2 03-21-2010 03:44 PM
Compiling 32 bit sample program on 64 bit fedora using -m32 option pankajdev Linux - Newbie 2 10-07-2009 07:42 AM
Problems Compiling/Running a Program on Ubuntu 8.10 Akinjide Linux - Software 1 09-24-2009 02:22 PM
help compiling a program minm Linux - Newbie 3 10-10-2005 01:14 AM
program for writing/compiling C++ in Fedora klmbrt Linux - Newbie 10 01-26-2005 06:58 AM


All times are GMT -5. The time now is 11:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration