How can I build and run 32-bit software on 64-bit Debian?

9,972

Yes, to use a 32-bit library you need to create a 32-bit binary.

On Debian 8 on amd64, you can build 32-bit binaries using gcc-multilib (for C) or g++-multilib (for C++) and GCC’s -m32 option.

Using CMake, I imagine adding -m32 to the flags would be sufficient. It is possible to set CMake up for both 32- and 64-bit builds in a single project, but it’s rather involved; see rr’s CMakeLists.txt for a detailed example.

To run 32-bit binaries, you’ll need to enable multi-arch support for i386:

sudo dpkg --add-architecture i386
sudo apt-get update

Then install the appropriate libraries, starting with libc6:i386 and libstdc++6:i386.

Share:
9,972

Related videos on Youtube

Roel Schroeven
Author by

Roel Schroeven

Updated on September 18, 2022

Comments

  • Roel Schroeven
    Roel Schroeven over 1 year

    I'm looking into developing a C++ program that needs a proprietary 32-bit library and which should run on 64-bit Debian (jessie, amd64). I assume I need to create a 32-bit executable in order to be able to use that 32-bit library (or is there a way to use that library from a 64-bit executable?)

    How can I build my program on 64-bit Debian? Or should I use a 32-bit Debian machine to build it, and transfer to the 64-bit Debian afterwards?

    I normally use cmake, if that makes any difference.