Skip to content
Advertisement

Compiling and linking a 32 bit application on Debian 64 bit

I am currently trying to compile and link a 32 bit application on my Debian 64 bit, but it fails at link time.

The command I’m using (in my Makefile) to compile is:

JavaScript

This seems to work.

Then I link with the following command:

JavaScript

This fails and gives the following errors:

JavaScript

What I’ve tried so far (usual solutions that I found elsewhere on the web) is:

  • installing gcc-multilib
  • installing lib32ncurses5 and lib32ncurses6dev
  • adding the option -L/usr/lib32 to the link command

Sadly, none of these has worked so far. I am running out of ideas. My last resort would be using a 32 bit system, but I’d like to avoid that if possible.

Advertisement

Answer

There are two problems:

  1. Your link command is incorrect: the order of libraries on the link line matters. The command should be: gcc -m32 $^ -o $@ -lcurses
  2. Since you want to link against ncurses, make the last argument -lncurses.
Advertisement