[leiningen] Re: Help packaging jni shared-objects in uberjar

  • From: Shlomi Vaknin <shlomivaknin@xxxxxxxxx>
  • To: leiningen@xxxxxxxxxxxxx
  • Date: Tue, 26 Sep 2017 19:06:22 -0700

Hi Daniel,

When I say "Everything works locally" I indeed mean it works well when
using lein repl and having LD_LIBRARY_PATH is set correctly.

Regarding your other point: its not that something went wrong, I simply
could not find any coherent explanation on how this is done. I tried to
follow some the code in lein itself (it has some native reference in the
tests), and tried to decipher what to do from various post in the old
google group for leiningen. At the end I did not manage to get the .so
files in the jar, and it was not clear how to use them even if they do end
up in it.

I followed the link you provided and it takes me (eventually) to how this
is achieved with maven. I also followed Neanderthal, and they too use maven
for the native part and require it in the leiningen/clojure part (as I
initially thought of doing).

It seems to me that there isn't a clear step-by-step guide on how to get
something like this done, I might just revert to using maven for the
java/jni/so portion and lein for the clojure one.

Thanks,
Shlomi


On Tue, Sep 26, 2017 at 5:45 PM, Daniel Compton <
daniel.compton.lists@xxxxxxxxx> wrote:

Hi Shlomi

When you say "Everything works locally", can you elaborate on this? Do you
mean when running a lein repl things work or something else?

I tried to follow almost everything I could find online regarding this,
but could not make it happen with lein.

What do you mean by this? What went wrong?

Not sure if you've seen https://github.com/jnr/jnr-ffi/issues/93 but it
might have some helpful links? Also Neanderthal and co. use native
libraries so may be useful (not sure as I haven't looked).

On Wed, Sep 27, 2017 at 1:01 PM Shlomi Vaknin <shlomivaknin@xxxxxxxxx>
wrote:

Hi all,

I am making an internal clojure library that wraps some cpp library.
Everything works locally, and I have the folder structure
"project/native/linux/x86_64/". Inside I have all the .so files that the
library needs.

I would like to package this and have it accessible just as a "maven"
artifact. My hope is that potential users could simply add the dependency
to their project.clj or pom files and have everything working (maybe even
without setting LD_LIBRARY_PATH manually)

I tried to follow almost everything I could find online regarding this,
but could not make it happen with lein. I could divide this project into a
"jni/maven" (maybe using something like that
<http://www.mojohaus.org/maven-native/native-maven-plugin/usage.html>)
and then have that as a dependency of my clj-library, but that seems a
little cumbersome.

Any tips on how to do that directly through lein?

Thanks,
Shlomi


Other related posts: