5

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. 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.

Commands that are also part of the binutils package, such as objdump or nm, give me the same file format error. The "file" command shows me:

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

and the "ldd" command shows:

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. 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.

linuxbuild
  • 15,843
  • 6
  • 60
  • 87
gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
  • 2
    on the same architecture? (i386 != amd64) – elmarco Nov 20 '09 at 16:27
  • I should have mentioned that the build platform and the target SuSE 10.2 platform are both x86_64. – gareth_bowles Nov 20 '09 at 16:45
  • You inspect the file format with objdump or by simply executing the .so (yes, this is possible). It will be ELF, because it is used since the stone age. If you have incompatible libc version you will get a error message which says exactly that - so your guess ist most likely wrong and the problem is probably something different. – Gunther Piez Nov 20 '09 at 19:41
  • Actually, objdump run on SuSE gives me the same "File format not recognized" error that the linker does. I've edited the question to reflect that and to show the output from the file and ldd commands, which do work. – gareth_bowles Nov 20 '09 at 21:02

6 Answers6

3

Windows has it problems with compatability between different realeases, service packs, installed SDKs, and DLLs in general (DLL Hell, anyone?). Linux is not immune to the same kinds of issues.

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).
  • Packager issues (RPM vs. APT)

In your particular case, I'd have them do a "gcc -v" on their system and report to you the gcc version number. Compare that to what you are using.

You might have to get hold of that version of the compiler to build your half with.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
3

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. 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.

I suspect by building on a nice new version of linux, it becomes difficult to support people on older machines.

(edit) I should mention that we use the default compiler that comes with Debian 4, which I think is GCC 4.1.2. Installing newer compiler versions tends to make compatibility much worse.

Matt T
  • 607
  • 3
  • 10
3

You can use Linux Application Checker tool ([1], [2], [3]) in order to solve compatibility problems of an application between Linux distributions. It will check your file formats and all dependent libraries. It supports almost all popular Linux distributions including all versions of SuSE and Fedora.

enter image description here

linuxbuild
  • 15,843
  • 6
  • 60
  • 87
2

This is just a personal opinion, but when distributing something in binary-only form on Linux, you have a few options:

  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. The first part is ideal but cumbersome. The latter part will lead you to point 2 and 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. Distribute binaries, and statically link where ever you can. Especially for libstdc++, which appears to be your problem here. There are seemingly very many incompatible versions of libstdc++ floating around, which makes it a compatibility nightmare. 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. 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.

Of course, distributing your project in source form is always preferred on Linux. :-)

asveikau
  • 39,039
  • 2
  • 53
  • 68
1

If the message is file format not recognized then the problem is most likely one mentioned by elmarco in a comment -- namely, different architecture. 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. 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.

Robert Obryk
  • 2,369
  • 1
  • 14
  • 6
0

I don't know about Suse, but I know fedora likes to stay on the bleeding edge. 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?

user183135
  • 3,095
  • 2
  • 18
  • 7