LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-12-2012, 01:05 PM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 528

Rep: Reputation: 32
Build for multiple Linux distro


Hi, a while back I recall if I build a C++ project on Centos it won't run on SuSE. Is there a way to specify the build options when running "g++" such that the final executable will run on all flavors of Linux, or specific distro of Linux?
 
Old 08-12-2012, 01:48 PM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,758

Rep: Reputation: Disabled
http://www.linuxfoundation.org/colla...oups/lsb/about
 
Old 08-12-2012, 01:55 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,935

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
There is no binary compatibility between linuxes. That's why developers distribute source packages.
 
Old 08-13-2012, 08:05 AM   #4
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,320

Rep: Reputation: 252Reputation: 252Reputation: 252
Quote:
Originally Posted by NevemTeve View Post
There is no binary compatibility between linuxes. That's why developers distribute source packages.
I wouldn’t phrase it this way. In principle something compiled for Cent OS will also run on openSUSE – as long as it’s the same CPU type. We bought several applications as binaries only and they run without problems. Missing libraries (or a wrong version of it) is one issue seen often. But it can be solved.

With more subtleties between CPU types, it can be necessary to chose a common factor during compilation. E.g. SSE4 is different between AMD and Intel as far as I know. In this case telling the compiler to use only 64bit commands but no SSE4 at all can help.

Last edited by Reuti; 08-13-2012 at 11:31 AM.
 
Old 08-13-2012, 08:11 AM   #5
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,563

Rep: Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804
Mozilla seem to do OK packaging Firefox to run on different distros. Don't they do this by including the majority of the library files required in the package?
 
Old 08-13-2012, 10:05 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by Reuti View Post
I wouldn’t phrase it this way. In principle something compiled for Cent OS will also run on openSUSE - as long as it’s the same CPU type. We bought several applications as binaries only and they run without problems.
I would consider much more than just the CPU type in the matter of cross-architecture compatibility. There are all kinds of layers of software, as well (kernel + drivers, standard C library, threading models, userspace libraries, etc). It's true that binaries are often cross-platform compatible, but that isn't guaranteed. Someone mentioned that Mozilla distributes cross-platform binaries as an example of compatibility. I would also point out that Mozilla browsers are by far the least reliable software I use on Linux. I don't know if there is a connection or not.

--- rod.
 
Old 08-13-2012, 10:35 AM   #7
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,563

Rep: Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804
Quote:
Originally Posted by theNbomr View Post
I would also point out that Mozilla browsers are by far the least reliable software I use on Linux. I don't know if there is a connection or not.
I think you're either unlucky or projecting some subconscious selection bias. That's not to say Mozilla products don't have problems, just that all software has problems and I've been using the Nightly build of Firefox on both 32 bit and 64 bit for a long while now with no reliability issues at all.
I think of it more that applications are written against a set of libraries and any distro with those libraries (and perhaps some going forward) can then run the application. Where the library is proprietary or a fixed version ought to be used it's bundled with the application.
There are far too many applications available which are not distro specific to go around saying things like:
Quote:
Originally Posted by NevemTeve View Post
There is no binary compatibility between linuxes. That's why developers distribute source packages.
The above is demonstrably not true.
 
Old 08-13-2012, 05:04 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by 273 View Post
applications are written against a set of libraries and any distro with those libraries (and perhaps some going forward) can then run the application.
But there are different versions/revisions of libraries, and by definition, those are not all the same. Yes, it mostly works, but there are no guarantees. I have seen occasions where it demonstrably does not work. It would be reasonable to imagine that there are even more cases where applications appear to work, but either subtly misbehave under certain conditions, or crash without evidence of the cause.

--- rod.
 
Old 08-13-2012, 05:10 PM   #9
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,320

Rep: Reputation: 252Reputation: 252Reputation: 252
Quote:
Originally Posted by theNbomr View Post
But there are different versions/revisions of libraries, and by definition, those are not all the same.
Therefore libraries have a major and minor revision number – or better: should have. This way you can have several versions installed, and the correct one is found by the compiled in soname to get the correct number of the major version used during compilation. Unfortunately are not all libraries following this scheme.
 
Old 08-13-2012, 05:19 PM   #10
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,212

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
In general, compiling your application with static libraries and in 32 bit will let it run on the VAST majority of regular Linux distros on standard hardware (not ARM, etc). Dynamic libraries and 64/32 bit incompatibilities are often what get you into trouble when distributing a pre-compiled binary.

I have a code that I compile for distribution in 32 bit with static libs. I've run it on RHEL, Fedora, CentOS, OpenSUSE, Ubuntu, Mint, Debian, and probably one or two more that I'm forgetting. The only machine I've found to date that won't run it is an old Fedora 4 box, because, according to the error, the kernel is too old.

Last edited by suicidaleggroll; 08-13-2012 at 05:25 PM.
 
Old 08-14-2012, 03:39 AM   #11
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,935

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
FYI: linux runs on dozens of different achitectures/processors, so binary compatibility is an illusion...
 
Old 08-14-2012, 10:54 AM   #12
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,563

Rep: Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804Reputation: 804
Quote:
Originally Posted by NevemTeve View Post
FYI: linux runs on dozens of different achitectures/processors, so binary compatibility is an illusion...
Your statement is a platitude.
Of course, without a virtual machine, a program written for one architecture will not work on a other. However, that does not mean that "binary compatibility is an illusion" it means that you compile for an architecture.
The original post may have been a little uspecific but your posts are meaningless and trite.
 
Old 08-14-2012, 11:46 AM   #13
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 3,212

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Quote:
Originally Posted by NevemTeve View Post
There is no binary compatibility between linuxes. That's why developers distribute source packages.
Quote:
Originally Posted by NevemTeve View Post
FYI: linux runs on dozens of different achitectures/processors, so binary compatibility is an illusion...
The OP didn't ask about compiling for different architectures, he specifically asked about compiling for different distributions. You're "answering" a question that was never asked.
 
Old 08-14-2012, 12:14 PM   #14
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,320

Rep: Reputation: 252Reputation: 252Reputation: 252
I didn’t dare to mention it before, but if we are getting into it: I was thinking of mentioning Mac OS X inherited fat binaries from NeXTSTEP to include PowerPC and Intel code. Nowadays it’s used to have 32 and 64 binaries in one binary for the Intel architecture (selectable with “open in 32 bit mode” in the info window of a file, and some even show “open with Rosetta” in addition for the PowerPC code).

And it looks like discussions about fat binaries are going on for Linux too.

Maybe this could also be used to include binaries for different versions of the kernel for one and the same architecture or a binary for Intel/AMD64/SSE4 in different flavors.
 
Old 08-14-2012, 12:47 PM   #15
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,935

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
Okay guys, you won, you certainly know better than me what 'all flavors on linux' in the original post means. EOF.
 
  


Reply


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
LXer: Linux Tycoon: A Game Where You... Build A Distro LXer Syndicated Linux News 1 04-03-2012 09:53 AM
LXer: Build Your Own Linux Distro LXer Syndicated Linux News 0 04-11-2009 11:20 PM
LXer: Build a Linux Distro You Can Be Proud Of LXer Syndicated Linux News 0 12-09-2008 02:10 AM
can't install ANY Linux distro on PC build lsudolemite Linux - Desktop 25 02-20-2008 06:20 PM
Build Custom Linux Distro/Flavor mmc Linux - Distributions 7 01-25-2005 05:57 AM


All times are GMT -5. The time now is 08:59 PM.

Main Menu
Advertisement
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