9

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!

user1383359
  • 2,673
  • 2
  • 25
  • 32

4 Answers4

6

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.

Roger Allen
  • 2,262
  • 17
  • 29
  • 2
    Thanks. With lein 2.3.1 I managed to get the following to work (no need for :jvm-opts):- :dependencies [[org.clojure/clojure "1.4.0"] [org.lwjgl.lwjgl/lwjgl "2.9.0"] [org.lwjgl.lwjgl/lwjgl-platform "2.9.0" :classifier "natives-osx" :native-prefix ""]] – actionshrimp Aug 14 '13 at 20:58
4

Looks like a problem with your LD_LIBRARY_PATH. Are you including the correct .dll or .so files?

You probably need to add something like :native-dependencies [[lwjgl "2.8.2"]] to your project.clj.

Alternatively, you could try setting the right value from your shell:

export LD_LIBRARY_PATH=/home/username/lwjgl-2.8.2/native/linux/
dbyrne
  • 59,111
  • 13
  • 86
  • 103
1

It's a bit confusing why Display is refusing to import, though other classes in the same jar file import properly

(import '[org.lwjgl.opengl Util WindowsAWTGLCanvasPeerInfo])

I suspect that this jar file is broken, perhaps you could try a different version.

I tried debuggin this by running

cd lib
jar xf lwjgl-2.8.2.jar
cd org/lwjgl/opengl/

and then trying to load various classes i see there.

lein swank also does tab completion which can help in exploring classes without extracting them from the shell.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
  • Wait, I don't think this addresses the core problem. I think this shows: "If I load things w/o native dependencies, it works; but I can't load things with native dependencies." – user1383359 May 11 '12 at 23:13
  • user1383359, I think your right, the difference is the native dependencies. – Arthur Ulfeldt May 11 '12 at 23:24
1

Ran into this today, solved it a bit differently by adding the native directory to :jvm-opts in project.clj:

(defproject projectname "0.0.1-SNAPSHOT"
  :description "my project"
  :jvm-opts ["-Djava.library.path=native/linux"]
  :dependencies [[org.clojure/clojure "1.4.0"]])

I copied the jar files from the latest lwjgl release into lib and copied the native directory into the project root. Seems to work so far:

user=> (import org.lwjgl.opengl.Display)
org.lwjgl.opengl.Display

But I am only just getting started. Anyway, hope this helps someone else :)

Tapio Saarinen
  • 2,499
  • 3
  • 20
  • 18