Merge pull request #18482 from profan/master

Fix shared lib loading for Unix, dlopen expects leading ./ for relative paths.
This commit is contained in:
Max Hilbrunner 2018-04-30 18:30:12 +02:00 committed by GitHub
commit 3204362cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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());