I'm trying to get ash (vulkan bindings) to work (on macOS). You're supposed give it environment variables, as explained in that link, and shown below. My super-small test program won't run if I put them in .cargo/config.toml
, but it will work if I set them in the shell. Am I doing something wrong with the Cargo config?
cat .cargo/config.toml
:
[env]
VULKAN_SDK = "/Users/rob/Dev/VulkanSDK/1.3.275.0/macOS"
DYLD_FALLBACK_LIBRARY_PATH = "/Users/rob/Dev/VulkanSDK/1.3.275.0/macOS/lib"
VK_ICD_FILENAMES = "/Users/rob/Dev/VulkanSDK/1.3.275.0/macOS/share/vulkan/icd.d/MoltenVK_icd.json"
VK_LAYER_PATH = "/Users/rob/Dev/VulkanSDK/1.3.275.0/macOS/share/vulkan/explicit_layer.d"
When I try to run it:
% cargo run -p bambu_ui --example hello_world
warning: /MonoRepo/bambu_ui/Cargo.toml: version requirement `0.38.0+1.3.275` for dependency `ash` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
[...]
Running `target/debug/examples/hello_world`
dyld[18267]: Library not loaded: @rpath/libvulkan.1.dylib
Referenced from: <F940628B-BBD4-3CE5-85DF-1F1DD73B0270> /MonoRepo/target/debug/examples/hello_world
Reason: tried: '/MonoRepo/target/debug/build/freetype-sys-bf3d0fcfa00bf77f/out/libvulkan.1.dylib' (no such file),
'/MonoRepo/target/debug/deps/libvulkan.1.dylib' (no such file),
'/MonoRepo/target/debug/libvulkan.1.dylib' (no such file),
'/Users/rob/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libvulkan.1.dylib' (no such file),
'/Users/rob/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libvulkan.1.dylib' (no such file),
'/Users/rob/lib/libvulkan.1.dylib' (no such file),
'/usr/local/lib/libvulkan.1.dylib' (no such file),
'/usr/lib/libvulkan.1.dylib' (no such file, not in dyld cache)
But if I set the same values directly in the shell, it then runs:
% cat vulk_env
export VULKAN_SDK=/Users/rob/Dev/VulkanSDK/1.3.275.0/macOS
export DYLD_FALLBACK_LIBRARY_PATH=${VULKAN_SDK}/lib
export VK_ICD_FILENAMES=${VULKAN_SDK}/share/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=${VULKAN_SDK}/share/vulkan/explicit_layer.d
% source vulk_env
% cargo run -p bambu_ui --example hello_world
warning: /MonoRepo/bambu_ui/Cargo.toml: version requirement `0.38.0+1.3.275` for dependency `ash` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
Compiling ash v0.38.0+1.3.281
Compiling ash-window v0.13.0
Compiling bambu_ui v0.1.0 (/MonoRepo/bambu_ui)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 15.67s
[...]
Running `target/debug/examples/hello_world`
Application::run <-- so it ran successfully this time.
Also not sure why it keeps recompiling ash at a different version from what I specified in my Cargo.toml.
[dependencies]
ash = { version = "0.38.0+1.3.275", features = ["linked"] }