Linking with 32Bit Libraries Under Linux 64Bit

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.

Use 32bit shared library from 64bit application?

You must be consistent. A 64-bit application can only use 64-bit libraries and a 32-bit application can only use 32-bit libraries. Both work; either choice is fine, and it's possible to compile the same code for both systems.

If you go for 'all 32-bit', use:

  • gcc -m32

If you go for 'all 64-bit', use:

  • gcc -m64

Sometimes, I'll tell make that the C compiler is gcc -m32 (or -m64) rather than just gcc to ensure the right value is used everywhere.

32 bit standard C library on 64 bit machine

Try this:

  apt-get install ia32-libs 

Also, you should compile/link with -m32:

gcc -Wall -pedantic -m32 ...


Related Topics



Leave a reply



Submit