Running 32-bit Applications on 64-bit Debian GNU/Linux
Posted by ajt on Mon 18 Jun 2007 at 10:51
Advanced Micro Devices (AMD) developed a series of 64-bit extensions to their 32-bit RISC-based Intel IA-32 (i386) compatible processors. AMD sell their AMD64 (x86-64) architecture processors under a range of names: Athlon 64; Turion 64; Phenom; Opteron and Sempron (only the latest generation).
Initially Intel chose not to extend their IA-32 processor family to 64 bits, preferring to promote their own but incompatible HP PA-RISC based IA-64 "Itanium" processor family, later Intel adopted AMD's 64-bit extensions into their IA-32 processor family, calling them "Intel 64" (aka IA-32e and EMT64). Final generation Pentium 4 & D, Celeron D, and Xeon processors and all "Core 2" based processors now include AMD compatible 64-bit extensions.
Most currently available AMD and Intel processors are 64-bit enabled. Other x86 compatible processors such as Via Technologies' C3 & C7, SiS 552 and AMD Geode are not 64-bit capable. Intel's Itanium family while 64-bit are not directly compatible with Intel's x86 architecture.
AMD's AMD64 and Intel's Intel64 are able to run in two basic modes: long mode - a 64-bit clean mode where most clean 32-bit applications can still run; and legacy mode - where the processor runs as if it were an older 32-bit processor supporting various obsolete legacy modes and there is no access to 64-bit features.
An AMD64 processor started in 64-bit mode can run 64-bit and 32-bit applications at the same time but if started in 32-bit mode cannot run 64-bit applications until it has been restarted. It is therefore possible to start a system in 64-bit mode and run 32-bit applications side-by-side with native 64-bit applications but you cannot run 64-bit applications on a system started in 32-bit mode.
Debian 64-bit
Debian GNU/Linux is available in two versions for AMD64 processors: i386 - is the traditional IA-32 version running in legacy mode; and AMD64 - is a new 64-bit version that takes full advantage of the new 64-bit features. In Debian 3.1 "Sarge" the AMD64 port was available and supported but declared "unofficial", in Debian 4.0 "Etch" it is a fully supported architecture. Within Debian, the i386 port has greater package coverage than the AMD64 port.
Although almost all packages are available compiled into native 64-bit AMD64 machine code, there is a handful of packages, in particular third party closed-source applications, that is not. These applications will not run directly in Debian AMD64. However, there are several methods to overcome this problem: dual boot/VM; a 32-bit chroot; and using the ia-32 suite.
Dual Boot/Virtual Machine
One crude and inefficient method of running 32-bit applications on a 64-bit system is to dual boot the system, one i386 installation and one AMD64 installation side-by-side. This works but is hardly practical - rebooting just to run a 32-bit application that is not supported on a 64-bit system is cumbersome and disruptive.
A slightly better approach is to install and run a complete 32-bit system on a virtual system such as Qemu or VMWare. As with dual booting, this works but it is clunky and slow.
32-bit chroot
The AMD64 processor is able to quickly switch between 32-bit and 64-bit modes on the fly, thus small static 32-bit applications should work perfectly on a 64-bit system without any modification to either the system or the application. Alas, most modern applications dynamically link to one or more libraries and it is essential that applications link to libraries of their own type or the program will fail.
One easy way to obtain this is to install a 32-bit system, complete with all libraries and applications but without a kernel, into a chroot. A chroot is a software device that creates a "jail" on the host's file system and applications running inside the jail cannot see out off it.
Creating and running a 32-bit chroot is clearly explained in the Debian AMD64 How-to linked below. It is relatively easy to do but like the dual boot and virtual machine solutions it requires a lot of disk space and is a lot of effort if you only need one 32-bit application.
ia32 Suite
The Debian system dynamic library linker has been modified so that when a 32-bit application requests access to a library, Debian provides the 32-bit version of the library if it is available instead of the normal 64-bit version that the native applications require. This works if the ia32 packages which provide a sub-set of standard Debian libraries compiled in 32-bit mode have been installed.
To install the ia32-libs package use the command
sudo aptitude install ia32-libs. This creates a document tree in the /emul/ia32-linux directory. By default this supports only console applications, basic X applications and GTK based applications. There are no 32-bit Qt or KDE libraries provided. If you want to run a Qt application, for example Opera, you should manually download, extract and install the 32-bit Qt libraries into this document tree, see apt-file code example below.
To find out what libraries are needed use the ldd command - be aware that the file you think starts the application is often a script, and you may have to dig a bit to find the actual binary. The example below is for Real's RealPlayer application, which is only available as 32-bit closed-source binary.
$ ldd /usr/lib/realplay-10.0.8/realplay.bin
linux-gate.so.1 => (0xffffe000)
libgdk-x11-2.0.so.0 => /usr/lib32/libgdk-x11-2.0.so.0 (0xf7ed2000)
libatk-1.0.so.0 => /usr/lib32/libatk-1.0.so.0 (0xf7eb8000)
... many deleted lines...
libpangoft2-1.0.so.0 => /usr/lib32/libpangoft2-1.0.so.0 (0xf7678000)
librt.so.1 => /lib32/librt.so.1 (0xf765d000)
/lib/ld-linux.so.2 (0xf7f6a000)
libfreetype.so.6 => /usr/lib32/libfreetype.so.6 (0xf75ea000)
Now all the required libraries have been found and RealPlayer should now be able to start without a problem.
If a library is missing use apt-file to locate the missing package. In the example below the linker needed to link to /usr/lib/compiz/libgconf-dump.so that was not
installed.
# Install and update apt-file $ sudo aptitude install apt-file $ sudo apt-file update # Search for the package containing the required library $ apt-file --architecture i386 search libgconf-dump.so compiz-plugins: usr/lib/compiz/libgconf-dump.so compiz-plugins: usr/lib/compiz/libgconf-dump.so compiz-plugins: usr/lib/compiz/libgconf-dump.so compiz-plugins: usr/lib/compiz/libgconf-dump.so # Download the 32-bit library you require $ wget http://ftp.uk.debian.org/debian/pool/main/c/compiz/compiz-plugins_0.2.2-1_i386.deb # Extract it into your 32-bit library tree $ sudo dpkg -X compiz-plugins_0.2.2-1_i386.deb /emul/ia32-linux
Note that some GTK applications such as RealPlayer start correctly but there is a font problem - all the glyphs are boxes rather than letters. To solve this you have to manually provide 32-bit Pango settings (from the Xara LX web site):
# Create a 32 bit pixbuf loaders file:
$ sed 's:/usr/lib/:/usr/lib32/:' < /etc/gtk-2.0/gdk-pixbuf.loaders > /etc/gtk-2.0/gdk-pixbuf.loaders32
# Create /etc/pango32/pangorc with the following in:
[Pango]
ModuleFiles=/etc/pango32/pango.modules
[PangoX]
AliasFiles=/etc/pango/pangox.aliases
# Insert the following environment variables into the environment that will
# start the application, e.g. a start script or you .bashrc
export GTK_PATH=/usr/lib32/gtk-2.0/
export PANGO_RC_FILE=/etc/pango32/pangorc
export GDK_PIXBUF_MODULE_FILE=/etc/gtk-2.0/gdk-pixbuf.loaders32
This is all that is required to run most 32-bit applications from within a 64-bit Debian system.
UPDATE: In Lenny and later the Debian ia32-libs-gtk package provides a valid gdk-pixbuf.loaders.32 file.
Summary
There are several methods of running 32-bit applications on top of a 64-bit platform. Of the methods presented above the ia32 libs method is the most elegant and seamless - though it does require some effort to configure and maintain. Dual booting is the simplest but is highly disk space inefficient and not recommended. The chroot method is inefficient too and is as complex as the ia32 approach so I would not recommend it if the ia32 method works.
- Version 1.00 / June 2007
- Wikipedia x64 article
- Debian AMD64 How To
- Using proprietary i386 apps on an amd64 system
- As ever, many thanks to the many people who have helped, in particular V. E. Kerguelen and D. K. Gillmor
One of the other applications that will not run on 64-bit Debian is Flash. Some people, myself included, feel that this is a benefit, not a drawback. :-)
[ Parent | Reply to this comment ]
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]
It is compiled as a 32 bit binary, and depends on ia32-libs and lib32asound among others, but it is a amd64 package that is installed normally.
http://www.winehq.org/site/download-deb
I bet something like this for debian would be pretty easy to put together, and then even though wine is compiled as a 32bit application, you no longer need to care since it is installed as a normal amd64 package...
Secondly, the best way I have found to get Flash is to use Swiftfox http://getswiftfox.com/ It is an optimized build of firefox (that part I don't really care about).
The thing I care about is it is compiled to run out of a single directory anywhere on the filesystem. No need to mess with trying to get the 32bit debian package extracted when it wants to run out of /usr/ or whatever.
They also have a 64bit download, which is compiled as a 32bit application. Be careful, they have two downloads "Athlon 64" and "Athlon 64 (32bit OS)" but the one you want is just "Athlon 64". At the top of the page it says... "All Swiftfox builds are 32-bit, including the AMD64 build."
So download the manual package, extract it in /opt/swiftfox, install ia32-libs and ia32-libs-gtk, and run /opt/swiftfox/swiftfox. Then go to any page with flash, and download the plugin. Works like a charm, no need to play with chroots, VMs, trying to force 32bit packages to work, etc...
John
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
http://forums.debian.net/viewtopic.php?p=87916#87916
"You give getlibs a path to a binary file and it will solve any dependencies that the binary needs.
On 64-bit systems it solves dependencies for both 32-bit binaries and 64-bit binaries.
On 32-bit systems it solves dependencies for 32-bit binaries."
It can also install 32-bit libraries by the name of the missing file.
[ Parent | Reply to this comment ]
Norb
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
dpkg --force-architecture
and expect a stern warning! To find out more about forcing things - which is normally a bad idea - type:
dpkg --force-help
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]
is it possible to install an i386 system, then to replace the i386 kernel with amd64 kernel and everything will be ok? so to have a true i386 system with an amd64 kernel?
thx
[ Parent | Reply to this comment ]
However, if you are running i386 Debian system and you have an AMD64 compatible processor you can install a kernel that is compiled to take advantage of the AMD64 processor. Try installing the package linux-image-2.6-amd64
--
"It's Not Magic, It's Work"
Adam
[ Parent | Reply to this comment ]
vim /usr/lib32/pango/1.5.0/module-files.d/libpango1.0-0.modules
:0,$s/lib/lib32/g
:wq
[ Parent | Reply to this comment ]
dpkg -X libesd-alsa0_0.2.36-3_i386.deb /emul/ia32-linux/
dpkg -X esound-clients_0.2.36-3_i386.deb /emul/ia32-linux/
Then editing /usr/bin/realplay to use the emul/ia32-linux version
(i.e. replacing the line
REALPLAYBIN=$HELIX_LIBS/realplay.bin
with
REALPLAYBIN="/emul/ia32-linux/usr/bin/esddsp $HELIX_LIBS/realplay.bin")
and editing /emul/ia32-linux/usr/bin/esddsp to use lib32 not lib.
Just had a segfault, though :-(
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Otherwise vmware-config.pl complained about missing libraries and VMWare was not able to start a virtual machine, giving an error "Unable to change virtual machine power state: Failed to connect to peer process."
[ Parent | Reply to this comment ]