Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to load vulkan on mac #2120

Closed
rongcuid opened this issue Jan 2, 2023 · 9 comments
Closed

Fail to load vulkan on mac #2120

rongcuid opened this issue Jan 2, 2023 · 9 comments

Comments

@rongcuid
Copy link

rongcuid commented Jan 2, 2023

Template

  • Version of vulkano: 0.32.0
  • OS: Mac OS 13.1
  • GPU (the selected PhysicalDevice): TODO
  • GPU Driver: TODO
  • Upload of a reasonably minimal complete main.rs file that demonstrates the issue: just use any example

Issue

When I try to run a Vulkano program, it fails to load Vulkan:

cargo run --bin basic-compute-shader
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `/Users/rongcuid/src/vulkano/target/debug/basic-compute-shader`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: LibraryLoadFailure(DlOpen { desc: "dlopen(libvulkan.1.dylib, 0x0005): tried: \'libvulkan.1.dylib\' (no such file), \'/System/Volumes/Preboot/Cryptexes/OSlibvulkan.1.dylib\' (no such file), \'/usr/lib/libvulkan.1.dylib\' (no such file, not in dyld cache), \'libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/src/vulkano/target/debug/build/shaderc-sys-d1970d87df1501e8/out/lib/libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/src/vulkano/target/debug/deps/libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/src/vulkano/target/debug/libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/.rustup/toolchains/stable-aarch64-apple-darwin/lib/libvulkan.1.dylib\' (no such file), \'/Users/rongcuid/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)" })', examples/src/bin/basic-compute-shader.rs:36:40

The library is in fact under /opt/local/lib. I don't know why Vulkano doesn't load it, because I have tried using Vulkan in C and that program can load the library normally.

@rongcuid
Copy link
Author

rongcuid commented Jan 2, 2023

It was Macport's problem. I installed directly from the installer and it works. I guess it's your choice to see whether this installtion option should be considered as an additional case

@Rua
Copy link
Contributor

Rua commented Jan 2, 2023

I don't know anything about Macs. What in Vulkano's code would need to be changed?

@rongcuid
Copy link
Author

rongcuid commented Jan 2, 2023

Maybe Vulkano is not responsible for loading the library. Perhaps the issue is elsewhere, maybe Ash. I will give it a look later.

@Rua Rua added the type: bug label Aug 14, 2023
@Soth1985
Copy link

LunarG Vulkan SDK installs the libraries to the /usr/local/lib path which dlopen does not search in, to fix can just add it to search path in https://github.com/vulkano-rs/vulkano/blob/a1307b6ef8dbcf77c3479c56bd354de7bc297a2e/vulkano/src/library.rs

#[cfg(target_os = "macos")]
            fn get_paths() -> [&'static Path; 4] {
                [
                    Path::new("libvulkan.dylib"),
                    Path::new("libvulkan.1.dylib"),
                    Path::new("libMoltenVK.dylib"),
                    Path::new("/usr/local/lib/libMoltenVK.dylib"),
                ]
            }

@marc0246
Copy link
Contributor

@Soth1985 I don't think absolute paths are the solution. When you install an application or libarary, it's supposed to be on the respective PATH so that it can be loaded by name.

@victor-rykov-playrix
Copy link

In RustRover setting environment variable also helps (exporting it to .profile .zprofile does not work)

image

@marc0246
Copy link
Contributor

marc0246 commented Nov 27, 2024

I can't believe what I'm reading. They mention in the SDK docs (the webside actively hates me trying to link to the specific heading, so scroll to "SDK System Paths" manually) that as of recent, macOS's dynamic linker no londer automatically searches in /usr/local/lib. They also mention that volk searches using the absolute path as a last resort and seemingly endorse that. So if that's how it is then I guess we should do the same.

@marc0246
Copy link
Contributor

I implemented the above ^ in #2614.

@Rua Rua closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@marc0246
Copy link
Contributor

Closed as the original issue as described is not something that's planned, that being MoltenVK installed in ways other than what volk and/or Vulkan SDK does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants