views:

263

answers:

3

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?

+3  A: 

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.

dash-tom-bang
+2  A: 

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.
mdma
A: 

You should be able to write a 64-bit wrapper that thunks into the 32-bit DLL, and have your JNI code call the 64-bit wrapper instead of the 32-bit DLL. Thunking is a fairly advanced and platform-dependent C/C++ topic.

EJP