我应该如何配置Vulkan for cider-jack-in?

时间:2016-07-30 13:44:47

标签: emacs clojure environment-variables vulkan cider

我正在使用Vulkan Tutorial处理Clojure中新发布的CIDER,我遇到了一些麻烦。示例makefile project完美无缺,但我无法将其翻译成Clojure。

我的build.boot文件只指定:source-paths并添加LWJGL作为依赖项:

(set-env!
 :source-paths #{"src"}
 :dependencies
 (let [lwjgl-version "3.0.0"]
   [['org.lwjgl/lwjgl lwjgl-version]
    ['org.lwjgl/lwjgl-platform lwjgl-version :classifier "natives-linux"]]))

然后,在src/example/core.clj中,我有一个使用vkEnumerateInstanceExtensionPropertiesextension-count函数,如原始示例所示:

(ns example.core
  (:import (org.lwjgl.vulkan VK10)))

(defn extension-count []
  (let [^String layer-name nil
        property-count (int-array 1)]
    (VK10/vkEnumerateInstanceExtensionProperties layer-name property-count nil)
    (first property-count)))

现在,从Bash开始,我可以在启动REPL时设置相关的环境变量LD_LIBRARY_PATHVK_LAYER_PATH

$ VULKAN_SDK_PATH=~/VulkanSDK/1.0.21.1/x86_64 LD_LIBRARY_PATH=$VULKAN_SDK_PATH/lib VK_LAYER_PATH=$VULKAN_SDK_PATH/etc/explicit_layer.d boot repl
boot.user=> (require '[example.core :refer [extension-count]])
nil
boot.user=> (extension-count)
4

如您所见,一切正常。但当然,当我使用{kbd> C-c M-j 的cider-jack-in时,我得到一个UnsatisfiedLinkError,因为CIDER没有设置这些变量:

boot.user> (import (java.util.function Consumer)
                   (org.lwjgl.system Configuration))
org.lwjgl.system.Configuration
boot.user> (Configuration/setDebugStreamConsumer
            (reify Consumer
              (accept [_ message]
                (println message))))
nil
boot.user> (require '[example.core :refer [extension-count]])
nil
boot.user> (extension-count)
[LWJGL] Failed to load a library. Possible solutions:
    a) Set -Djava.library.path or -Dorg.lwjgl.librarypath to the directory that contains the shared libraries.
    b) Add the JAR(s) containing the shared libraries to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
java.lang.UnsatisfiedLinkError: Failed to locate library: libvulkan.so.1

我应该按照上述错误消息中的建议而不是java.library.path来设置org.lwjgl.librarypathLD_LIBRARY_PATH吗?我可以设置profile.boot中的任何一个变量:

(System/setProperty
 "java.library.path"
 (str (System/getProperty "user.home") "/VulkanSDK/1.0.21.1/x86_64/lib"))

现在当我再次尝试 C-c M-j 时,它有效:

boot.user> (require '[example.core :refer [extension-count]])
nil
boot.user> (extension-count)
4

但是,这仍然不允许我设置VK_LAYER_PATH,这在将来会非常重要:

  

我们将开始在Vulkan中使用验证层,您需要告诉Vulkan库使用VK_LAYER_PATH变量加载这些文件:

     
test: VulkanTest
    LD_LIBRARY_PATH=$(VULKAN_SDK_PATH)/lib VK_LAYER_PATH=$(VULKAN_SDK_PATH)/etc/explicit_layer.d ./VulkanTest

如何为cider-jack-in设置这些环境变量?我不想在单独的终端中为standalone repl手动配置CIDER的依赖关系,然后使用cider-connect连接到它,但如果这里没有其他选项,我想这就是我要做的必须这样做。

0 个答案:

没有答案