summaryrefslogtreecommitdiff
path: root/drivers/unix
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-01-04 15:42:29 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-01-04 15:43:06 -0300
commit6e2ed15ff14efe3063f66c182218f56e557bb468 (patch)
tree378040107d3d7722160f596be5e6756496ef345e /drivers/unix
parent7555fdc0035533773a6bc1d54b9bc00b9d7d1a3e (diff)
Add support from properly exporting shared objects, needed for GDNative export
Diffstat (limited to 'drivers/unix')
-rw-r--r--drivers/unix/os_unix.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index fa8094f31a..e08b58cf5c 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -362,7 +362,20 @@ String OS_Unix::get_locale() const {
}
Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
- p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
+
+ String path = p_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());
+ }
+
+ if (!FileAccess::exists(path)) {
+ //this code exists so gdnative can load .so files from a standard unix location
+ path = get_executable_path().get_base_dir().plus_file("../lib").plus_file(p_path.get_file());
+ }
+
+ p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
if (!p_library_handle) {
ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
ERR_FAIL_V(ERR_CANT_OPEN);