简体   繁体   English

如何包装32位.dll以便它可以在64位操作系统中运行

[英]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. 所以,我一直在使用JPIB与我的java程序中的GPIB设备进行通信。 However, I have run into a snag. 但是,我遇到了麻烦。 Newer systems are built on 64 bit OS's. 较新的系统基于64位操作系统。 However, the jpib.dll file is written in 32-bit. 但是,jpib.dll文件是用32位编写的。 I can't think of any kind of calls that it would need to make that are truly 64-bit dependent. 我想不出它需要做出的真正64位依赖的任何类型的调用。

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. 真正的麻烦在于,自2006年9月以来,JPIB项目还没有更新。我曾尝试通过SourceForge向开发者发送电子邮件,但我认为我不会随意使用它。

Does anyone know of any ways around this? 有没有人知道这方面的任何方法? Or know how (and could tell me how) to recompile the .dll into AMD-64 compliance? 或者知道如何(并且可以告诉我如何)将.dll重新编译为AMD-64合规性?

Note: I have no idea what JPIB and GPIB are. 注意:我不知道JPIB和GPIB是什么。

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. 如果要按原样使用DLL,那么您需要编写一个可以动态链接该DLL并通过某种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. 如果要重建该DLL,则需要获取源及其所有依赖项并安装构建工具。 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. 这应该不会太难,但如果您正在安装MS Visual Studio,我似乎需要一些关于安装x64内容的问题。 This may depend on your install platform, though; 这可能取决于您的安装平台; if you're installing on x64 presumably it'll Just Work. 如果你在x64上安装,大概就是Just Work。

A 32-bit VM will still work on a 64-bit AMD platform, and Intel EMT64 platforms. 32位虚拟机仍可在64位AMD平台和英特尔EMT64平台上运行。

However, if you want to use the library in a 64-bit process, you can use java to help you out. 但是,如果要在64位进程中使用库,可以使用java来帮助您。 The solution uses 2 JVMs - a 32-bit one and a 64-bit one - the 64-bit one hosts your main application. 该解决方案使用2个JVM - 一个32位和一个64位 - 64位主机应用于您的主应用程序。 The 32-bit one hosts the JPIB library. 32位的主机托管JPIB库。 You then use RMI to bridge between them. 然后,您可以使用RMI在它们之间进行桥接。 In more detail: 更详细:

  • the JPIB library has quite a small API. JPIB库有一个相当小的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. 通过直接调用JPIB类来实现接口。 You use RMI to expose this interface via RMI, from a 32-bit JVM. 您可以使用RMI通过RMI从32位JVM公开此接口。
  • In your 64-bit JVM you use RMI to get an instance of the JPIB interface from the 32-bit VM. 在64位JVM中,您使用RMI从32位VM获取JPIB接口的实例。 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. 您现在可以将该接口上的方法调用为本地方法,但它们实现为对32位VM的远程调用以供执行。

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. 您应该能够编写一个64位的包装程序,它可以在32位DLL中运行,并让您的JNI代码调用64位包装器而不是32位DLL。 Thunking is a fairly advanced and platform-dependent C/C++ topic. Thunking是一个相当高级且与平台相关的C / C ++主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM