我正在使用 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
, and libtest_linux_amd64.so
)我希望所有这些都打包到一个罐子中并由一个罐子支持。
有没有办法通过运行一次 JNAerator 来实现这种“一体化”方法,或者我必须为每个平台生成不同的 jar 文件?
JNAerator 有一个-arch
专为此设计的选项,尽管该文档目前对此非常模糊 https://code.google.com/p/jnaerator/wiki/CommandLineOptionsAndEnvironmentVariables:
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 https://code.google.com/p/bridj/ (see 关于嵌入式二进制文件的 wiki 页面 https://code.google.com/p/bridj/wiki/LibrariesLookup):
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
目前预计库名称准确无误lib<name>.(so|dylib)
or <name>.dll
对于每个平台,尽管这很容易修复如果你问 https://github.com/nativelibs4java/JNAerator/issues.
(注:我是 BridJ & JNAerator 的作者)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)