What exactly does gcc-multilib mean on Ubuntu?

35,202

Solution 1

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

Solution 2

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.

Share:
35,202

Related videos on Youtube

ddbug
Author by

ddbug

Beware programmers who carry screwdrivers!

Updated on September 18, 2022

Comments

  • ddbug
    ddbug over 1 year

    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?

  • ddbug
    ddbug over 7 years
    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 ?
  • AlexP
    AlexP over 7 years
    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.
  • ddbug
    ddbug over 7 years
    Thank you AlexP. Is this multilib setup new for Ubuntu 16, or it existed earlier, say in v.14 or even 12?
  • AlexP
    AlexP over 7 years
    12.04 at least.