Compiling and Linking a 32 Bit Application on Debian 64 Bit

Compiling and linking a 32 bit application on Debian 64 bit

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.

How to Compile 32-bit Apps on 64-bit Ubuntu?

To get Ubuntu Server 12.04 LTS 64-bit to compile gcc 4.8 32-bit programs, you'll need to do two things.

  1. Make sure all the 32-bit gcc 4.8 development tools are completely installed:

    sudo apt-get install lib32gcc-4.8-dev

  2. Compile programs using the -m32 flag

    gcc pgm.c -m32 -o pgm

Linking with 32bit libraries under linux 64bit

Well, you can't mix and match 32-bit and 64-bit code. If you compile all your code using -m32 (to make it build as 32-bit), you may be able to get your application to link if you have 32-bit versions of all your libraries available.

Linking 32-bit library to 64-bit program

No. You can't directly link to 32bit code inside of a 64bit program.

The best option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use a form of inter-process communication to communicate to it from your 64bit program.



Related Topics



Leave a reply



Submit