我有 .dll 库,其中包含用 C++ 编写的头文件(没有可用的源代码)。这个库使用了其他一些 .dll 文件 - 我也有它们。我的任务是从 Java 使用这个库(调用方法并接收结果)。
我发现可以使用 JNAerator 来实现此目的。会是什么算法?我尝试了 java -jar jnaerator.jar MyLib.dll MyLibHeader.h 命令,但它输出
ERROR: JNAeration failed !
Missing output mode parameter -mode !
Please use -h for help on the command-line options available.
如何使用 -h 寻求帮助?我需要哪种模式?示例命令中只有一个 dll,但我想使用其中三个,因为它们相互依赖。
也许它是更适合我的任务的工具? (一些教程将不胜感激)。谢谢。
最佳答案
您需要在命令行中指定-mode
参数。
他们的Google Code页面有这样的内容:
-mode [mode: 'Jar' : JAR with bindings only | 'StandaloneJar' : JAR with bindings and runtime dependencies | 'Directory' : Bindings sources in simple file hierarchy | 'Maven' : Bindings sources in Maven project ready to build | 'AutoGeneratedMaven' : Maven project that automatically regenerates its bindings>]
假设您使用“StandaloneJar”,那么您的命令行将是:
java -jar jnaerator.jar -mode StandaloneJar MyLibHeader.h MyLib.dll
。
我希望它能起作用,因为我完全没有使用 JNAenerator 的经验!
关于java - 从 Java 调用 dll(C++ 库)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14294366/