Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using lwjgl in Leiningen/Clojure

Tags:

clojure

Solution

(1) (println (. System getProperty "java.library.path"))

This gives me a list of places java looks for native extensions.

Then, I took the lwjgl native extensions, and put them there.

Things that didn't work for me (probably because I used them incorrectly)

(*) setting :native-path
(*) setting :native-dependencies

Problem

My setup:

(lein deps; echo "====="; cat project.clj; echo "====="; cat src/main.clj; echo "====="; lein repl) &> log

contents of "log"

    Copying 10 files to /Volumes/ramdisk/fail/lib
=====
(defproject
  mincase "0.0.1"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.lwjgl.lwjgl/lwjgl "2.8.2"] ]
  :repositories {"local" "/Users/x/z/maven_repo"}
  :jvm-opts ["-Xms4g"  "-Xmx4g"]
  :repl-init main
  )

=====
(ns main
 (:import org.lwjgl.opengl.Display)) 
=====
REPL started; server listening on localhost port 31235
UnsatisfiedLinkError no lwjgl in java.library.path  java.lang.ClassLoader.loadLibrary (ClassLoader.java:1860)
clojure.core=> 

Note -- I had already done a "lein deps", so the lwjgl library has been pulled into maven. What I don't understand are:

(*) how do I get access to lwjgl from Clojure?
(*) more importantly, how do I debug which step this whole thing has gone wrong at?

$ find lib

lib
lib/clojure-1.4.0.jar
lib/jinput-2.0.5.jar
lib/jinput-platform-2.0.5-natives-linux.jar
lib/jinput-platform-2.0.5-natives-osx.jar
lib/jinput-platform-2.0.5-natives-windows.jar
lib/jutils-1.0.0.jar
lib/lwjgl-2.8.2.jar
lib/lwjgl-platform-2.8.2-natives-linux.jar
lib/lwjgl-platform-2.8.2-natives-osx.jar
lib/lwjgl-platform-2.8.2-natives-windows.jar

So it appears that lwjgl has been pulled in.

What are the steps I should try to figure out which step I went wrong on?

Thanks!

like image 334
user1383359 Avatar asked May 11 '12 21:05

user1383359


1 Answers

Dropping this note here since google found this post for my similar question.

The Leiningen folks have now addressed this: https://github.com/technomancy/leiningen/issues/898

If you get version 2.1.0 or later, it has the fix. See the bug for details.

UPDATE: (Aug 2013)

I have a project on github I use for experimentation with lwjgl here: https://github.com/rogerallen/hello_lwjgl

I'm also using LWJGL in my shadertone project here: https://github.com/overtone/shadertone Because Shadertone is a library, I found I needed to package up the natives myself to get it to install reasonably for projects that depend on shadertone.

If anyone has some pull with the LWJGL folks, it sure would be nice if they just put natives into appropriate subdirectories as lein expects in their clojars releases.

like image 81
Roger Allen Avatar answered Oct 21 '22 21:10

Roger Allen