This question already has an answer here:

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.

marked as duplicate by Gilles debian Mar 21 '17 at 23:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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 the 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.

  • Thank you, this works! I just had to install g++-multilib instead of just gcc-multilib (edited your answer to mention that). There was no need, apparently, for dpkg --add-architecture i386. It's possible that I have done that at some point in the past. – Roel Schroeven Mar 21 '17 at 10:08
  • Ah yes, I forgot you explicitly mentioned C++. You probably did add the architecture at some point in the past ;-). (It's not enabled by default in Debian, unlike Ubuntu; but it's safe to run the dpkg command multiple times so it's easier to just include in instructions like these.) – Stephen Kitt Mar 21 '17 at 10:10
  • I have no need for 32- and 64-bit builds in a single project, so I'm not even going to try that now. Thank you for the info though. – Roel Schroeven Mar 21 '17 at 10:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.