Using lwjgl in Leiningen/Clojure

前端 未结 4 1412
独厮守ぢ
独厮守ぢ 2021-01-02 10:00

Solution

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

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

相关标签:
4条回答
  • 2021-01-02 10:42

    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 :)

    0 讨论(0)
  • 2021-01-02 10:49

    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/
    
    0 讨论(0)
  • 2021-01-02 10:50

    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.

    0 讨论(0)
  • 2021-01-02 10:50

    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.

    0 讨论(0)
提交回复
热议问题