[SOLVED] Compiling a program both for Fedora and Ubuntu
Linux - SoftwareThis 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.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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?
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.
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.
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.
Files created on Ubuntu 8.04 should usually work
on Fedora 13.
They do not when loading .so's of Fedora. See above
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).
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
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.
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.
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.
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.
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.
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).