Having trouble loading your dynamic libraries from inside an app-folder on macOS? Tried setting both DYLD_LIBRARY_PATH
and DYLD_FALLBACK_LIBRARY_PATH
through scripts without success? So did I, and here is how I managed to solve it:
First copy the library next to the binary inside the app-folder:
Then add a rpath
to the binary pointing to @loader_path/.
:
After this you should be able to load the library during runtime. This is super useful if you are trying to load libraries that the binary has not been linked against during build. I ran into this problem when using using LuaJit FFI functions in projects bundled with Defold.