Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to wrap 32-bit .dll so it will work in a 64-bit OS

So, I've been using JPIB to communicate with GPIB devices in my java program. However, I have run into a snag. Newer systems are built on 64 bit OS's. However, the jpib.dll file is written in 32-bit. I can't think of any kind of calls that it would need to make that are truly 64-bit dependent.

The real trouble here is that the JPIB project hasn't been updated since september of 2006. I've tried emailing the dev through SourceForge but I don't think I'll get anywhere with that.

Does anyone know of any ways around this? Or know how (and could tell me how) to recompile the .dll into AMD-64 compliance?

like image 312
Campin Carl Avatar asked May 27 '10 22:05

Campin Carl


People also ask

Can I use a 32-bit DLL in 64-bit application?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL. However, 64-bit Windows supports remote procedure calls (RPC) between 64-bit and 32-bit processes (both on the same computer and across computers).


2 Answers

Note: I have no idea what JPIB and GPIB are.

If you want to use the DLL as-is, then you'll need to write an application that can dynamically link that DLL and communicates with your application via some sort of IPC.

If you want to rebuild that DLL, then you'll need to get the source and all of its dependencies and install the build tools. This shouldn't be too tough although if you're installing MS Visual Studio I seem to require a couple of gotchas regarding getting the x64 stuff installed. This may depend on your install platform, though; if you're installing on x64 presumably it'll Just Work.

like image 107
dash-tom-bang Avatar answered Sep 29 '22 18:09

dash-tom-bang


A 32-bit VM will still work on a 64-bit AMD platform, and Intel EMT64 platforms.

However, if you want to use the library in a 64-bit process, you can use java to help you out. The solution uses 2 JVMs - a 32-bit one and a 64-bit one - the 64-bit one hosts your main application. The 32-bit one hosts the JPIB library. You then use RMI to bridge between them. In more detail:

  • the JPIB library has quite a small API. Unfrotunately, it's implemented all as classes. You abstract the library by implementing interfaces that have the same method signatures as the main driver classes.
  • Implement the interface by calling the the JPIB classes directly. You use RMI to expose this interface via RMI, from a 32-bit JVM.
  • In your 64-bit JVM you use RMI to get an instance of the JPIB interface from the 32-bit VM. You can now call methods on that interface as if they were local, but they are implemented as remote calls to the 32-bit VM for execution.
like image 21
mdma Avatar answered Sep 29 '22 19:09

mdma