diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2018-04-30 18:30:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-30 18:30:12 +0200 |
commit | 3204362cd101dd400810f6475c114e26e77ff66b (patch) | |
tree | 5e8bef4024c075fc5041f9cbee541969cb05cc3c | |
parent | f1bbb596534d473b531d0cab21e4cf75658a29b8 (diff) | |
parent | 828744195526e44a30d07c232db25066cf0fc984 (diff) |
Merge pull request #18482 from profan/master
Fix shared lib loading for Unix, dlopen expects leading ./ for relative paths.
-rw-r--r-- | drivers/unix/os_unix.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 31c8e4ade9..eeb3b31fc2 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -349,6 +349,12 @@ Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle String path = p_path; + if (FileAccess::exists(path) && path.is_rel_path()) { + // dlopen expects a slash, in this case a leading ./ for it to be interpreted as a relative path, + // otherwise it will end up searching various system directories for the lib instead and finally failing. + path = "./" + path; + } + if (!FileAccess::exists(path)) { //this code exists so gdnative can load .so files from within the executable path path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); |