So as a continuation of the last post
http://orphanware.blogspot.com/2012/08/making-c-available-through-native-calls.html....here is how you do it in clojure
download jna.jar and platform.jar
write clojures codes!
(defn helloworld ( []
( let [ lib ( com.sun.jna.NativeLibrary/getInstance "mylib" ) ]
( let [ helloWorld ( .getFunction lib "MYLIB_helloWorld" ) ]
( println ( .invokeVoid helloWorld null ) ) ) ) ) )
( helloworld )
then run with
java -cp /usr/share/java/clojure.jar:jna.jar:. -Djna.nosys=true clojure.main helloworld.clj
No comments:
Post a Comment