Multiarch lets you install packages from multiple architectures on the same machine. This is useful in various ways, but the most common is installing both 64 and 32-bit software on the same machine and having dependencies correctly resolved automatically.
There is a current machine architecture, as printed by dpkg --print-architecture. It is built-in to the currently installed dpkg package.
Packages are now specified as 'Package:Architecture' pretty-much anywhere that was previously just 'Package', so we have libc:i386 and lib:amd64. The bare name 'package' refers to the current machine architecture.
Other available architectures are shown by dpkg --print-foreign-architectures. dpkg will manage packages for these architectures as well as the machine architecture.
There is a 'Multi-Arch' header in the package metadata of any multiarch-aware package.
Existing packages work fine in a multiarch environment, just as before, but to gain the benefits of co-installation or cross-architecture dependencies, many packages need to be made 'multiarch-aware'.
- For an unchanged package you can choose which arch version of a package to install (e.g. 'amd64' or 'i386').
- If a package is marked 'Multi-Arch: foreign', then it can satisfy dependencies of a package of a different architecture (e.g 'make:amd64' will satisfy a dependency on make for any-architecture package).
- To enable more than one architecture version of a package to be installed at the same time (generally libraries and dev- packages) files need to be moved so they don't clash. These packages are marked 'Multi-Arch: same'.
Packages marked 'Multi-Arch : allowed also exist which can be treated as either :same or :foreign depending on how they are depended-on. See the multiarch spec and implementationhowto for details of this.
You need a multiarch-aware dpkg and apt.
check dpkg support is present with
In Debian this is present since 1.16.2. In Ubuntu this is present since natty (v1.16.0)
Apt is multiarch-aware if it supports -o APT::Architectures. This is available from version 0.8.13 onwards. However there are many multiarch-related improvements and bug-fixes in later apt versions, such as apt-get build-dep -a cross-dependency support, so the later the better in general up to at least 0.9.4.
Prior to apt 0.9 in Debian, dpkg can get stuck during upgrades when it is not told which arch package it should be configuring by apt. (dpkg: error: --configure needs a valid package name but 'gcc-4.7-base' is not: ambiguous package name 'gcc-4.7-base' with more than one installed instance) dpkg --configure -a will unbung this.
To add an extra parchitecture:
dpkg --add-architecture <arch>
dpkg-architecture --add-architecture armhf
To remove an achitecture
dpkg --remove-architecture <arch>
dpkg architectures are stored in /var/lib/dpkg/arch.
setting up apt sources
Apt defaults to using the set of architectures reported by dpkg, and any unqualified architecture deb lines in /etc/apt/sources.list, which is usually what you wanted. This can be overridden using APT::Architecture=<arch> to set the defalt architecture or APT::Architectures="<arch> <arch>".
apt-sources can be architecture qualified with this syntax. This is very useful on Ubuntu's split archive. It is not normally necessary on Debian unless your normal archive does not mirror the extra architectures you are intereted in.
deb [arch=amd64.i386] http://uk.archive.ubuntu.com/ubuntu/ quantal main universe deb [arch=armel,armhf] http://ports.ubuntu.com/ubuntu-ports quantal main universe
Arch-qualifying deb-src lines doesn't make any sense.
Don't forget to apt-get update after adding new architectures.
To install a package of the non-default architecture just specify that architecture on the command line:
apt-get install package:architecture
That package's dependencies will be installed automatically for the correct architectures (same-arch library deps, machine-arch for other deps) e.g
apt-get install links:i386
dpkg -i package:architecture
To install build-dependencies of a package before cross-building:
apt-get build-dep -a <arch> <package>
Details of how this resolves are on the