bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.65k stars 737 forks source link

Are preset maven artifacts portable? #1424

Open benshiffman opened 10 months ago

benshiffman commented 10 months ago

I just followed the directions on the "Create New Presets" page and successfully wrapped a native library of my own. My question is, how portable is the artifact that appears in my .m2/repositories folder? Ideally, I would like to have the wrapped lib as a standalone package that others on my team (provided they are on the same platform, windows-x86_64) can access without having to go through the javacpp install/build procedures themselves. Is this as simple as sharing the jar file?

As a somewhat-related follow-up, what is the difference between the (libname) and (libname)-platform artifacts?

Thanks!

saudet commented 10 months ago

Yes, just sharing the JAR files should work, as long as you bundle all the dependencies in those JAR files.

The platform artifacts on https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies

benshiffman commented 10 months ago

Do you mean bundling the contents of (lib)/target? I read through reducing the number of dependencies and that all makes sense. It seems though that by file size alone that the binaries are not contained in (lib).jar, (lib)-platform.jar, nor (lib)-windows-x86_64.jar. Under the (lib)/target/native folder I do see that the jni binaries are being copied, but the original static and dynamic libraries don't seem to be connected.

saudet commented 10 months ago

You'll need to add those in the @Platform annotation as per https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes

benshiffman commented 10 months ago

Yup, I've included and linked all the headers and libs that I need following that.

benshiffman commented 10 months ago

I've been able to call native functions from a project using this as a dependency without a problem, just looking for a way to get these onto other devs' systems without going through the build process again.

saudet commented 10 months ago

Please follow the instructions at https://github.com/bytedeco/javacpp-presets/wiki/Debugging-UnsatisfiedLinkError-on-Windows

benshiffman commented 10 months ago

Hadn't stumbled across that before--dependencywalker was very helpful. Seems like the (lib)-(platform).jar contains all that is needed. Thanks!