help with "use the NAR plugin to create a JNI type library for multiple platforms"

145 views
Skip to first unread message

dma...@gmail.com

unread,
Apr 24, 2017, 10:30:28 AM4/24/17
to NAR Maven plugin
Hello


Can someone elaborate on how to create a NAR artifact that contains versions of a native library compiled for different platforms? The FAQ answer to the question "How do I use the NAR plugin to create a JNI type library for multiple platforms (Windows, MacOSX and Linux)?" says something I can't even parse in plain English: "Additionally, you need to specify which will be used to load the native libraries." -- what does this mean? What does "which" refer to in the aforementioned sentence?

Concretely, can someone outline the steps necessary to combine multiple native libraries (one for each platform) in a single artifact?  In other words, mvn package on Linux, MacOS, and Windows each will create the same jar (let's say my.nar) with Java bindings to the native library, and three different binary files, e.g. libmy.so, libmy.dylib, and libmy.dll. Then how to create an artifact package that contains all of these: my.narlibmy.solibmy.dylib, and libmy.dll?   From what the FAQ answer says, I can't see how this is to be done.

Thanks.

Curtis Rueden

unread,
Apr 24, 2017, 10:49:32 AM4/24/17
to dma...@gmail.com, NAR Maven plugin, Stefan Helfrich, Ulrik Guenther
Hi Dmitri,

Some members of the SciJava community (CCed; they may have additional comments) are in the process of exploring and developing a new cloud-CI-based process for doing what you want, since our projects have the same need. The Jenkins-based solution which the NAR FAQ currently describes is not written up very well, I agree. We hope to write up a better guide which leverages Travis CI and Appveyor to achieve Windows, macOS and Linux builds at least for 64-bit, if not also 32-bit via cross-compilation.

One key thing in the approach we are currently exploring is the exists-maven-plugin [1], which avoids trying (and failing) to deploy the same POM when multiple CI systems build the same version on different architectures.

If you are impatient, we can point you to the current build configurations we are playing with. Otherwise, we can ping the NAR list again once we have stabilized a working solution and written up the new guide.

Regards,
Curtis



--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden


--
You received this message because you are subscribed to the Google Groups "NAR Maven plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-nar+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Curtis Rueden

unread,
Apr 24, 2017, 10:53:58 AM4/24/17
to dma...@gmail.com, NAR Maven plugin, Stefan Helfrich, Ulrik Guenther
Hi Dmitri,

> our projects have the same need.

Just to clarify one thing: to do what you ask—make an uber-JAR with multiple platforms embedded—is a multi-step process. We are currently focused on the first step: building and deploying the native libraries to a remote Maven repository successfully.

Once the first step is done, you then need to perform a second step: assemble the multiple architectures into a single uber-JAR. This second step is done in the same way as usual with Maven: create a POM that depends on the different platforms you want, and assemble them using the maven-assembly-plugin or maven-shade-plugin.

Here is one possible way of accomplishing that:


Personally, I would not recommend creating an uber-JAR unless you really need it for some reason. See http://imagej.net/Uber-JAR for rationale and discussion.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden


Dmitri Makarov

unread,
May 2, 2017, 1:51:31 PM5/2/17
to Curtis Rueden, NAR Maven plugin, Stefan Helfrich, Ulrik Guenther
Hi Curtis,

Thank you for the reference to curve-fitter pom.xml. I'll try to use it as an example for my project.  From briefly looking at the pom.xml I noticed that the only nar dependency there seems to be slim-curve library and, if I understand correctly, it is expected that it exists, among other versions, as a dll built by MSVC -- is that correct?  However, I don't see anywhere in slim-curve's pom.xml that you explicitly set up msvc settings.  How does it work?  I'm currently having trouble setting up the build of my project on Windows, with a recent community version of VisualStudio installed.  I specify

<msvc>
  <version>15.0</version>
  <windowsSdkVersion>10.0.15063.0</windowsSdkVersion>
</msvc>

in the <configuration> subsection of nar-maven-plugin section, and I can't pass through nar-validate goal, because of the error: "msvc.windowsSdkVersion not specified".  Does it work for you, or you don't use VisualStudio toolchain on Windows?


Regards,

Dmitri
Reply all
Reply to author
Forward
0 new messages