简体   繁体   English

Linux发行版之间的二进制兼容性

[英]Binary compatibility between Linux distributions

Sorry if this is an obvious question, but I've found surprisingly few references on the web ... 对不起,如果这是一个显而易见的问题,但我发现很少有人在网上引用...

I'm working with an API written in C by one of our business partners and supplied to us as a .so binary file, built on Fedora 11. We've been testing out the API on a Fedora 11 development machine with no problems. 我正在使用我们的业务合作伙伴用C编写的API,并将其作为.so二进制文件提供给我们,构建在Fedora 11上。我们已经在Fedora 11开发机器上测试了API,没有任何问题。 However, when I try to link against the API on our customer's target platform, which happens to be SuSE Enterprise 10.2, I get a "File format not recognized" error. 但是,当我尝试链接客户目标平台上的API(恰好是SuSE Enterprise 10.2)时,我收到“文件格式无法识别”错误。

Commands that are also part of the binutils package, such as objdump or nm, give me the same file format error. 同样属于binutils包的命令,例如objdump或nm,给出了相同的文件格式错误。 The "file" command shows me: “file”命令显示我:

ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

and the "ldd" command shows: 并且“ldd”命令显示:

ldd: warning: you do not have execution permission for `./libuscuavactivity.so.1.1'
./libuscuavactivity.so.1.1: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./libuscuavactivity.so.1.1)
[dependent library list]

I'm guessing this is due to incompatibility between the C libraries on the two platforms, with the problem being that the code was compiled against a new version of glibc etc. than the one available on SuSE 10.2. 我猜这是由于两个平台上的C库之间不兼容,问题是代码是针对新版本的glibc等编译的,而不是SuSE 10.2上提供的版本。 I'm posting this question on the off chance that there is a way to compile the code on our partner's Fedora 11 platform in such a way that it will run on SuSE 10.2 as well. 我发布这个问题是因为有一种方法可以在我们的合作伙伴的Fedora 11平台上编译代码,这样它也可以在SuSE 10.2上运行。

Windows has it problems with compatability between different realeases, service packs, installed SDKs, and DLLs in general (DLL Hell, anyone?). Windows在不同的版本,服务包,已安装的SDK和一般的DLL(DLL Hell,任何人?)之间存在兼容性问题。 Linux is not immune to the same kinds of issues. Linux不能免于同样的问题。

The compatability issues I have seen include: 我见过的兼容性问题包括:

  • Runtime library changes 运行时库更改
  • Link library changes 链接库更改
  • Kernel changes 内核更改
  • Compiler technology changes (eg: pre and post EGCS gcc versions. This might be your issue). 编译器技术发生变化(例如:EGCS gcc版本之前和之后。这可能是您的问题)。
  • Packager issues (RPM vs. APT) Packager问题(RPM与APT)

In your particular case, I'd have them do a "gcc -v" on their system and report to you the gcc version number. 在您的特定情况下,我会让他们在他们的系统上执行“gcc -v”并向您报告gcc版本号。 Compare that to what you are using. 将其与您正在使用的内容进行比较。

You might have to get hold of that version of the compiler to build your half with. 您可能必须掌握该版本的编译器以构建您的一半。

I think the trick is to build on a flavour of linux with the oldest kernel and C library versions of any of the platforms you wish to support. 我认为诀窍在于使用您希望支持的任何平台的最旧内核和C库版本来构建Linux的风格。 In my job we build on Debian 4, which allows us to officially support Debian 4 and above, RedHat 3,4,5, SuSE 10 plus various other distros (SELinux etc.) in an unofficial fashion. 在我的工作中,我们以Debian 4为基础,允许我们以非官方方式正式支持Debian 4及以上版本,RedHat 3,4,5,SuSE 10以及其他各种发行版(SELinux等)。

I suspect by building on a nice new version of linux, it becomes difficult to support people on older machines. 我怀疑通过构建一个不错的新版本的Linux,很难支持旧机器上的人。

(edit) I should mention that we use the default compiler that comes with Debian 4, which I think is GCC 4.1.2. (编辑)我应该提一下,我们使用Debian 4附带的默认编译器,我认为是GCC 4.1.2。 Installing newer compiler versions tends to make compatibility much worse. 安装较新的编译器版本往往会使兼容性更差。

You can use Linux Application Checker tool ( [1] , [2] , [3] ) in order to solve compatibility problems of an application between Linux distributions. 您可以使用Linux Application Checker工具( [1][2][3] )来解决Linux发行版之间的应用程序的兼容性问题。 It will check your file formats and all dependent libraries. 它将检查您的文件格式和所有依赖库。 It supports almost all popular Linux distributions including all versions of SuSE and Fedora. 它支持几乎所有流行的Linux发行版,包括所有版本的SuSE和Fedora。

在此输入图像描述

This is just a personal opinion, but when distributing something in binary-only form on Linux, you have a few options: 这只是个人观点,但是当在Linux上以二进制形式分发内容时,您有以下几种选择:

  1. Build the gamut of .debs and .rpms for every distro under the sun, with a nominal ".tar.gz full of binaries" package for anything you've missed. 为阳光下的每个发行版构建.debs和.rpms的色域,使用名为“.tar.gz的二进制文件”包,用于您错过的任何内容。 The first part is ideal but cumbersome. 第一部分是理想的,但很麻烦。 The latter part will lead you to point 2 and 3. 后一部分将引导您进入第2点和第3点。

  2. Do as some are suggesting and find the oldest distro you can find and build there. 做一些人的建议,找到你能找到并在那里建造的最古老的发行版。 My own opinion is this is sort of a ridiculous idea. 我个人认为这是一个荒谬的想法。 See point 3. 见第3点。

  3. Distribute binaries, and statically link where ever you can. 分发二进制文件,并在任何地方静态链接 Especially for libstdc++, which appears to be your problem here. 特别是对于libstdc ++,这似乎是你的问题。 There are seemingly very many incompatible versions of libstdc++ floating around, which makes it a compatibility nightmare. 似乎有许多不兼容的libstdc ++版本浮出水面,这使它成为兼容性的噩梦。 If you can't link statically, you can also put *.so files alongside your binary, and use stuff like LD_PRELOAD or LD_LIBRARY_PATH to make them link preferentially at runtime. 如果无法静态链接,还可以将* .so文件放在二进制文件旁边,并使用LD_PRELOADLD_LIBRARY_PATH类的东西使它们在运行时优先链接。 Note that if you take this route you may have to comply with LGPL etc. since you are now distributing other people's work alongside your project. 请注意,如果您采用这种方式,您可能必须遵守LGPL等,因为您现在正在与项目一起分发其他人的工作。

Of course, distributing your project in source form is always preferred on Linux. 当然,在Linux上始终首选以源代码形式分发项目。 :-) :-)

If the message is file format not recognized then the problem is most likely one mentioned by elmarco in a comment -- namely, different architecture. 如果消息是文件格式无法识别,则问题很可能是elmarco在评论中提到的问题 - 即不同的架构。 It might (I'm not sure) be a dynamic linker version mismatch, but that would mean the .so file was built with an ancient dynamic linker. 它可能(我不确定)是动态链接器版本不匹配,但这意味着.so文件是使用古老的动态链接器构建的。 I do not believe any incompatibility in libc could cause this -- they could cause link failures and runtime problems (latter very rarely), but not this. 我不相信libc中的任何不兼容性都可能导致这种情况 - 它们可能导致链接失败和运行时问题(后者很少),但不是这样。

I don't know about Suse, but I know fedora likes to stay on the bleeding edge. 我不知道Suse,但我知道Fedora喜欢留在最前沿。 So you may very well be right about library versions. 所以你可能对图书馆版本非常正确。 Why don't you ask and see if you can get the source code and build it on your Suse machine? 你为什么不问,看看你是否可以获得源代码并在你的Suse机器上构建它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM