19

After hanging long time with older Ubuntu (v.12) I'm updating to v.16 and am very confused with mentions of "gcc-multilib".

Is this actually Apple's "fat binaries" or "universal binaries" model ported to Linux?

That is, have native C libraries on Ubuntu become containers that pack several binaries for various architectures?

If so, we no longer have to specially install 32-bit runtime libs on a x64 system? The "default" package of gcc or g++ libraries contains all needed to run and build 32-bit apps?

2 Answers 2

20

gcc-multilib is useful for cross-compiling, that is, compiling a program to run on a different processor architecture. For example, you would need gcc-multilib if you are running on 64-bit Ubuntu and want to compile a program to run on 32-bit Ubuntu (or on ARM etc. you get the idea).

4
  • 1
    So, it is not related to runtime libraries? Do we still need to go thru the hoops and install "libc-i386", "g++-i386" and so on 32-bit libs to run 32-bit programs on x64? And is "dpkg --add-architecture i386" related to multilib ?
    – ddbug
    Dec 1, 2016 at 23:28
  • Yes. The usual hoops. dpkg --add-architecture simply tells dpkg that you really want to install packages for foreign architecture and it should stop complaining and requesting --force-architecture.
    – AlexP
    Dec 1, 2016 at 23:35
  • Thank you AlexP. Is this multilib setup new for Ubuntu 16, or it existed earlier, say in v.14 or even 12?
    – ddbug
    Dec 1, 2016 at 23:45
  • 12.04 at least.
    – AlexP
    Dec 1, 2016 at 23:49
1

Is this actually Apple's "fat binaries" or "universal binaries" model ported to Linux?

No.

Multilib is a mechanism to support building and running code for different ABIs for the same CPU family on a given system. Most commonly it was/is used to support 32-bit code on 64-bit systems and 64-bit code on 32-bit systems with a 64-bit kernel. It was also used at one stage to provide support for soft-float arm binaries on hard-float arm systems.

It has been around for a long time. Since at least Debian lenny, but it never had specific support in the packaging tools making library support awkward. Also on arm upstream treats the 64-bit and 32-bit architectures as completely separate architectures rather than variants of the same architecture, so you can't use multilib there.

In terms of running code on Debian and Ubuntu systems, multilib has been mostly replaced by multiarch, which is a more general mechanism allowing installation of packages from potentially any combination of architectures on the same system (though actually running those binaries may require installing emulation layers).

In terms of building code Debian/Ubuntu now offer proper cross-compiler packages, which are more flexible than multilib in that they in principle allow you to build for anything on anything (though in practice Debian doesn't offer the full set of combinations).

So I think multilib is mostly legacy at this time, it sticks around though because important packages still nedd it to build.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.