Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load 32-bit shared library from 64-bit application?

I have a shared library that is compiled as 32-bit. Can I use it from a 64-bit application or do I need to compile the shared library as 64-bit as well?

like image 249
Brian Avatar asked Apr 19 '11 18:04

Brian


2 Answers

No, you cannot load a 32-bit library in a 64-bit application through conventional means.

There are some clever hacks out there such as having a 32-bit application which loads the library and exports the functions through an IPC interface, but if you have the option to compile the library as 64-bit, then that is by far the best choice.

like image 68
Evan Teran Avatar answered Oct 14 '22 10:10

Evan Teran


You cannot load dynamically or statically a 32-bit library from a 64-bit application or vice versa.

There are a number of work-arounds that I am aware of:

  1. Make a 64-bit version of the DLL
  2. Make a 32-bit version of the application
  3. Introduce a COM proxy object (also called a surrogate) as a communication intermediary. Described here.
  4. Host the DLL in a separate (32-bit) EXE and use an IPC technique

There are a number of inter-process communication (IPC) techniques. Here are a few examples:

  • named pipe
  • windows messsages
  • socket
  • HTTP listener
  • WCF service (described here)
  • .NET remoting
like image 36
cdiggins Avatar answered Oct 14 '22 11:10

cdiggins