如何在一个标题下使用JNAerator和多个动态库? [英] How to use JNAerator with multiple dynamic libraries under one header?

查看:867
本文介绍了如何在一个标题下使用JNAerator和多个动态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JNAerator生成一个我可以包含在项目中的jar文件,我想支持每个操作系统的动态库并在这个jar中进行全部归档。



到目前为止,在摆弄JNAerator时,我已经能够使用如下命令包含一个动态库:

  java -jar jnaerator.jar test.dll test.h [...] -mode StandaloneJar 

但是,这只包装 test.dll ,而我有多个系统的动态库( test_win32.dll test_win64.dll libtest_mac.dylib libtest_linux_x86.so libtest_linux_amd64.so )我希望所有人都打包并由一个jar支持。



<有没有办法用一次JNAerator运行这个一体化方法,还是我必须为每个平台生成一个不同的jar文件?

解决方案

JNAerator有一个 -arch 选项专为此而设计,尽管该文档目前对此非常模糊

  java -jar jnaerator-0.12-shaded。 jar \ 
-arch win32 win32 / test.dll \
-arch win64 win64 / test.dll \
-arch darwin_universal mac / libtest.dylib \
- arch linux_x86 linux_x86 / libtest.so \
-arch linux_x64 linux_amd64 / libtest.so \
test.h \
-mode StandaloneJar \
-jar test.jar

这将以BridJ (请参阅其有关嵌入式二进制文件的Wiki页面):



unzip -l test.jar 给出:

  ... 
0 04-09-15 22:45 lib / win32 / test.dll
0 04-09-15 22:45 lib / win64 / test.dll
0 04-09-15 22:45 lib / darwin_universal / libtest.dylib
0 04- 09-15 22:45 lib / linux_x86 / libtest.so
0 04-09-15 22:45 lib / linux_x64 / libtest.so

库名称目前应该是 lib< name>。(so | dylib)< name> .dll 适用于所有平台,尽管可以轻松修复如果您要求



(注意:我是BridJ& amp;的作者JNAerator)


I am using JNAerator to generate a single jar file I can include in a project, and I'd like to support the dynamic libraries for each operating system and arch all in this single jar.

In fiddling with JNAerator so far, I've been able to include a single dynamic library using a command like the following:

java -jar jnaerator.jar test.dll test.h [...] -mode StandaloneJar

However, this only packages test.dll, while I have dynamic libraries for multiple systems (test_win32.dll, test_win64.dll, libtest_mac.dylib, libtest_linux_x86.so, and libtest_linux_amd64.so) which I would like to all have packaged into and supported by one jar.

Is there any way to do this "all-in-one" approach with one run of JNAerator, or must I generate a different jar file for each platform?

解决方案

JNAerator has an -arch option designed just for that, although the doc is currently terribly vague about it:

java -jar jnaerator-0.12-shaded.jar \
  -arch win32 win32/test.dll \
  -arch win64 win64/test.dll \
  -arch darwin_universal mac/libtest.dylib \
  -arch linux_x86 linux_x86/libtest.so \
  -arch linux_x64 linux_amd64/libtest.so \
  test.h \
  -mode StandaloneJar \
  -jar test.jar

This will bundle the libraries under the format expected by BridJ (see its wiki page about embedded binaries):

unzip -l test.jar gives:

    ...
    0  04-09-15 22:45   lib/win32/test.dll
    0  04-09-15 22:45   lib/win64/test.dll
    0  04-09-15 22:45   lib/darwin_universal/libtest.dylib
    0  04-09-15 22:45   lib/linux_x86/libtest.so
    0  04-09-15 22:45   lib/linux_x64/libtest.so

The library names are currently expected to be exactly lib<name>.(so|dylib) or <name>.dll for every platform, although that could easily be fixed if you ask.

(note: I'm the author of BridJ & JNAerator)

这篇关于如何在一个标题下使用JNAerator和多个动态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆