GNU/Linux / Running 32-bit applications on 64-bit Linux

From WhyNotWiki

Jump to: navigation, search

GNU/Linux / Running 32-bit applications on 64-bit Linux  edit   (Category  edit)


http://tghc.org/32apps.html provides a pretty good how-to.

I wrote my own how-to based on http://tghc.org/32apps.html. It is specific to installing the game N, but can easily be generalized:


[edit] How I installed N on 64-bit Linux

How I installed N on 64-bit Linux edit


Metanet Software was kind enough to provide a Linux version of N available for download at http://www.harveycartel.org/metanet/downloads.html (http://www.harveycartel.org/metanet/n_v1linux.tar.gz). Unfortunately, it is a binary only (no source) and it is compiled for a 32-bit architecture (mine is 64-bit).

I extracted the archive to ~/bin/n_v1linux.

How to confirm that it's a 32-bit binary:

~/bin/n_v1linux$ file ./n_v14 
./n_v14: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

(To run 32-bit apps on 64-bit Linux, you first need to install these prerequisite packages: sudo apt-get install ia32-libs ia32-libs-gtk ia32-libs-sdl dpkg-dev.)

What happened when I first tried to run it:

~/bin/n_v1linux$ ./n_v14 
./n_v14: error while loading shared libraries: libgtk-1.2.so.0: cannot open shared object file: No such file or directory

At first I tried simply installing libgtk-1.2 using Synaptic. That's not enough, because that only installs the 64-bit version (at /usr/lib/libgtk-1.2.so.0.9.1):

$ locate libgtk-1.2.so.0
/usr/lib/libgtk-1.2.so.0.9.1
/usr/lib/libgtk-1.2.so.0
/home/tyler/bin/n_v1linux/libgtk-1.2.so.0

$ file /usr/lib/libgtk-1.2.so.0
/usr/lib/libgtk-1.2.so.0: symbolic link to `libgtk-1.2.so.0.9.1'

$ file /usr/lib/libgtk-1.2.so.0.9.1 
/usr/lib/libgtk-1.2.so.0.9.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), stripped

At first I thought the problem was simply that N wasn't looking in the right places and wasn't finding the library it needed.

So I tried to trick N into using the 64-bit shared library I'd just installed by doing this:

$ sudo cp /usr/lib/libgtk-1.2.so.0 /usr/lib32/libgtk-1.2.so.0

No such luck. You can't mix 32-bit binaries (applications) and 64-bit binaries (shared libraries)!

~/bin/n_v1linux$ ./n_v14 
./n_v14: error while loading shared libraries: libgtk-1.2.so.0: wrong ELF class: ELFCLASS64

[edit] Finding and "installing" the 32-bit version of the libraries you need

This is what I did:

[This part could be made into a generic template.]

Go to http://packages.ubuntu.com/

Find the section "Search the contents of packages"

Enter the file name that it complained that it could not find.

[This part could be an instance of that template with specifics added.]

In the case of this error:

./n_v14: error while loading shared libraries: libgtk-1.2.so.0: cannot open shared object file: No such file or directory

, you take the file name (libgtk-1.2.so.0) and search for that.

Of the 2 results given, I selected the most reasonable one. It listed:

  • libdevel/libgtk1.2-dbg [universe]
  • libs/libgtk1.2 [universe]

I didn't want a development library, so I clicked on the only remaining alternative: the link for libs/libgtk1.2, which led to http://packages.ubuntu.com/gutsy/libs/libgtk1.2.

Once on that page, I found the "Download libgtk1.2" section and clicked the link for the desired architecture: i386, which is 32-bit.

From that page, I selected a mirror and actually downloaded the file, saving it in ~/Downloads.

Using Nautilus (you could probably do this from the command line, but I don't know how), I went to ~/Downloads, right-clicked on libgtk1.2_1.2.10-18_i386.deb and selected Open with "Archive Manager".

From there, I opened the data.tar.gz archive and extracted the /./usr/lib/ folder into ~/Downloads.

Then I copied those files to /usr/lib32/

$ sudo cp -r lib/* /usr/lib32/

How can I do this from the command line?

Well, it looks like I can use dpkg-deb to extract the files -- I don't need Nautilus or Archive Manager at all for that!

$ dpkg-deb --extract libgtk1.2_1.2.10-18_i386.deb libgtk-1.2

~/Downloads$ ls libgtk-1.2/usr/lib/
libgdk-1.2.so.0  libgdk-1.2.so.0.9.1  libgtk-1.2.so.0  libgtk-1.2.so.0.9.1

I wonder if there's some way to use dpkg -i to install it and force it to install into /usr/lib32 ... ?

[edit] Repeat process

That wasn't enough. There remained 2 more libraries I needed to manually install to /usr/lib32/.

~/bin/n_v1linux$ ./n_v14 
./n_v14: error while loading shared libraries: libgmodule-1.2.so.0: cannot open shared object file: No such file or directory
:~/bin/n_v1linux$ ./n_v14 
./n_v14: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

I followed the same process for these.

I ran it with

$ nice -n 20 ./n_v14

The performance still wasn't very smooth though.

 


Personal tools