开发者

How to compile for legacy os

I am using Cent OS 5.

It h开发者_如何学JAVAas legacy package installed.

With what version of gcc should I compile ?

Does it really required to compile with old gcc version to support old linux os ?

if yes why ?


I'm going to start off by saying that the easiest way to get software builds that will work on CentOS 4, or even older, is to build the code on those target distributions, or ship your code with some scripts/tools to make it easy to recreate a build on that machine. If you've ever downloaded a source code release, and did the /.configure && make && make install steps, this is what I'm talking about.

Those source releases are built upon the GNU Autotools system, which gives you auto-configuration (it determines what can and can't be used on the target system) and generates a makefile to build with.

There are alternatives to the GNU Autotools system (which, frankly, I find a chore to learn and use), like cmake and scons. Here is a page (on scons) which compares the popular build tools:

http://www.scons.org/wiki/SconsVsOtherBuildTools

So what if you still want to build on your CentOS 5 machine for older CentOS installs?

Now for why you do need legacy libraries and compilers to build with, if you want to build on your CentOS 5 system:

So you have CentOS 5, which runs this toolchain:

gcc 4.1.2
glibc 2.5.x
libstdc++ 4.1.2

And CentOS 4, which runs this toolchain:

gcc 3.4.x
glibc 2.3.x
libstdc++ 3.4.x

The big problem is that if you were to just build C or C++ software with the standard CentOS 5 tools, they would be linked to the CentOS 5 C and C++ libraries (glibc, libstdc++, libgcc), and these libraries are not backward compatible with older releases. That is, software built for glibc 2.5.5 is in no way guaranteed to run with glibc 2.4, or even glibc 2.5.4 (though unless there are special circumstances, you would be able to run glibc 2.4-built software on glibc 2.5.x). You will also need to build the dependencies against the older library versions.

When you go even older, you will need to build a cross-compiler (look up crosstool) that will allow you to target builds for older systems, that will link to the older versions of libc and other dependencies built against that as well.

Is there something else besides building on the target and such?

You could static link all your dependencies into the binary, so you wouldn't have to worry about the dependencies and such. However, I have never done such a thing and I forget if there was some problem to linking glibc statically, or if I'm thinking of some other major library that posed issues with static linking (on a technical level).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜