Managing Native Dependencies with Leiningen

This post will cover the steps required to package, deploy and use native dependencies with leiningen.

First we need to package native libs according to the spec, native libs (.so,.jnilib,.dll) will go into the native/ folder. Folder structure I used to package RxTx libs for Mac OS X is,


The naming convention is important.

Mac OS X -> macosx
Windows  -> windows
Linux    -> linux
SunOS"   -> solaris

amd64    -> x86_64
x86_64   -> x86_64
x86      -> x86
i386     -> x86
arm      -> arm
sparc    -> sparc

Next step is to Jar them up,

jar -cMf rxtx-macosx-native-deps-2.1.7.jar native

Before we push to clojars we need to create a POM file for it,

<?xml version="1.0" encoding="UTF-8"?>

Then push to clojars with,

scp pom.xml rxtx-macosx-native-deps-2.1.7.jar [email protected]:

Now native dependencies are ready for deployment, assuming we want to create new project which depends on RxTx, we create a new leiningen project adding RxTx jars as dependencies,

(defproject ardu-test "0.0.1-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.clojars.nakkaya/rxtx "2.1.7"]
                 [org.clojars.nakkaya/rxtx-macosx-native-deps "2.1.7"]])