Running 32-bit Applications on 64-bit Debian GNU/Linux

Posted by ajt on Mon 18 Jun 2007 at 10:51

Tags: ,

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.

 

 


Posted by paulgear (203.206.xx.xx) on Tue 19 Jun 2007 at 08:41
[ Send Message ]
One of the significant applications that will not run on 64-bit Debian is Wine. This means that one must run some sort of VM technology to get Windows emulations. (Not that i'm complaining - VMware Server works extremely well for me.)

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 ]

Posted by ajt (204.193.xx.xx) on Tue 19 Jun 2007 at 08:55
[ Send Message | View Weblogs ]
Yes, I've had no luck with WINE, but flash works perfectly inside a 32-bit browser such as Opera. I'd agree that flash is not necessarily a good thing though!

--
"It's Not Magic, It's Work"
Adam

[ Parent | Reply to this comment ]

Posted by wuzzeb (64.5.xx.xx) on Tue 19 Jun 2007 at 09:35
[ Send Message ]
Recent versions of the official wine packages from winehq.org have added a 64bit package for Ubuntu Feisty. (I use Ubuntu on my desktop computer, debian on the servers so I really only care about wine on my desktop...)

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 ]

Posted by Anonymous (163.1.xx.xx) on Wed 24 Oct 2007 at 15:53
FWIW, I've successfully built wine from the winehq.org GIT repository on Etch/AMD64 and it works fairly well (i.e. as well as it ever does). I can even run 16-bit windows apps :-)

[ Parent | Reply to this comment ]

Posted by Anonymous (212.152.xx.xx) on Tue 19 Jun 2007 at 13:39
For those who want to go the VM-way: yes, VMware server works quite well, but it's closed source, and thus not always the best option. A tool I can recommend is VirtualBox (virtualbox.org), which is a standard VM-application like VMware, but is dual-licensed under some commercial thingy, and the GPL. It has a nice and easy GUI, and thus offers the best mix between the userfriendly but proprietary VMWare, and the openness of qemu.

[ Parent | Reply to this comment ]

Posted by paulgear (203.206.xx.xx) on Tue 3 Jul 2007 at 06:24
[ Send Message ]
BTW, thanks for spelling out that pango config stuff - that makes it possible to use Acrobat Reader on my etch AMD64 system!

[ Parent | Reply to this comment ]

Posted by Anonymous (70.185.xx.xx) on Mon 23 Jul 2007 at 00:28
Also see the script getlibs:
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 ]

Posted by norb (74.130.xx.xx) on Tue 24 Jul 2007 at 17:17
[ Send Message ]
I just wanted to say thank you. This bit of information has been a big help.

Norb

[ Parent | Reply to this comment ]

Posted by Anonymous (212.50.xx.xx) on Mon 6 Aug 2007 at 08:53
But how do you install the 32-bit .debs? dpkg -i package.deb spits out complaints about not matching the architecture...

[ Parent | Reply to this comment ]

Posted by ajt (85.211.xx.xx) on Mon 6 Aug 2007 at 09:07
[ Send Message | View Weblogs ]
dpkg has a force option, so you tell it to force the architecture:

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 ]

Posted by Anonymous (78.106.xx.xx) on Thu 9 Aug 2007 at 18:49
hello
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 ]

Posted by ajt (85.211.xx.xx) on Thu 9 Aug 2007 at 20:12
[ Send Message | View Weblogs ]
No. You can't directly install an i386 system, then swap in a kernel from the AMD64 port of Debian and expect it to run properly - lots of things just won't work.

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 ]

Posted by Anonymous (213.162.xx.xx) on Tue 14 Aug 2007 at 20:20
If you have trouble with pango (lots of squares instead of fonts), note you also need to edit /usr/lib32/pango/1.5.0/module-files.d/libpango1.0-0.modules and change all instances of /usr/lib/ to /usr/lib32/, eg with

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 ]

Posted by Anonymous (213.162.xx.xx) on Tue 14 Aug 2007 at 20:46
I've also got sound (sort of) working with realplayer using ESD. I modified the /usr/bin/realplay script to use esddsp

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 ]

Posted by Anonymous (213.162.xx.xx) on Tue 14 Aug 2007 at 21:00
Works OKish if you disable custom sampling rates in realplayer. ESD does seem to buffer the sound which can lead to strange effects if you try to move about in the video. Pausing the video until the ESD buffer is empty (or whatever it is causing the effect has passed) then trying again seems to work OK.

[ Parent | Reply to this comment ]

Posted by Anonymous (163.1.xx.xx) on Wed 24 Oct 2007 at 15:44
Using oss-alsa works a lot better as it doesn't have the latency issues ESD does. Seems to work OK with other sound playing, too. Not sure what the point of ESD is.

[ Parent | Reply to this comment ]

Posted by Anonymous (84.19.xx.xx) on Wed 26 Dec 2007 at 18:17
Thank you for your info. I solved my problem with x86_64 VMWare Workstation 6.0.2 by installing ia32-libs.
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 ]

Posted by vuorio (213.103.xx.xx) on Sun 28 Nov 2010 at 19:51
[ Send Message ]

I believe:

sudo apt-file update
needs to be complemented for other architectures as necessary, e.g.:
sudo apt-file --architecture i386 update

[ Parent | Reply to this comment ]

Posted by Anonymous (95.36.xx.xx) on Tue 21 Feb 2012 at 09:40
Users reading this article should be aware that Debian is moving to support the simultaneous installation of binaries of different architecture ("multiarch"). Ref, e.g.: the Multiarch page in the Debian wiki.

[ Parent | Reply to this comment ]

Posted by Anonymous (204.193.xx.xx) on Tue 21 Feb 2012 at 09:48
Multiarch is indeed the future, however there is now very little 32-bit software than isn't available as 64-bit that it's not as serious a problem as it once was.

[ Parent | Reply to this comment ]

Posted by Anonymous (91.48.xx.xx) on Mon 30 Jun 2014 at 03:01
apt-file -a i386 update

saves time

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

Which init system are you using in Debian?






( 1637 votes ~ 7 comments )

 

 

Related Links