summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2023-12-20 14:02:32 -0800
committerGitHub <noreply@github.com>2023-12-20 14:02:32 -0800
commit443b10b6d4cd4c889565e8478b3e512ee02ea898 (patch)
tree328935d48ba6aee15e8ace5c6c6e5c2cf4e9bc2d
parent816998ea1e6b6546bc24d912478708219494962c (diff)
parent3277a37352ac6fec2b1158beeaffbbf96f2a3b8a (diff)
downloadvolk-443b10b6d4cd4c889565e8478b3e512ee02ea898.tar.gz
Merge pull request #164 from zeux/apple-usr-local
Fall back to /usr/local/lib/libvulkan.dylib on macOS
-rw-r--r--volk.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/volk.c b/volk.c
index 85fb0a7..074cfd0 100644
--- a/volk.c
+++ b/volk.c
@@ -17,6 +17,10 @@
# include <dlfcn.h>
#endif
+#ifdef __APPLE__
+# include <stdlib.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,6 +72,10 @@ VkResult volkInitialize(void)
module = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
if (!module)
module = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL);
+ // modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says
+ // Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails
+ if (!module && getenv("DYLD_FALLBACK_LIBRARY_PATH") == NULL)
+ module = dlopen("/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
if (!module)
return VK_ERROR_INITIALIZATION_FAILED;