diff options
Diffstat (limited to 'src')
4 files changed, 29 insertions, 7 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java index 32aa7eb..b1671b9 100644 --- a/src/java/com/jogamp/common/os/DynamicLinker.java +++ b/src/java/com/jogamp/common/os/DynamicLinker.java @@ -51,4 +51,5 @@ public interface DynamicLinker { public long lookupSymbol(long libraryHandle, String symbolName); public long lookupSymbolGlobal(String symbolName); public void closeLibrary(long libraryHandle); + public String getLastError(); } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index bfc5b07..3009ef3 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -186,13 +186,26 @@ public class NativeLibrary implements DynamicLookupHelper { for (Iterator<String> iter = possiblePaths.iterator(); iter.hasNext(); ) { String path = iter.next(); if (DEBUG) { - System.err.println("NativeLibrary.open(): Trying to load " + path); + System.err.println("NativeLibrary.open(global "+global+"): Trying to load " + path); } long res; - if(global) { - res = dynLink.openLibraryGlobal(path, DEBUG); - } else { - res = dynLink.openLibraryLocal(path, DEBUG); + try { + if(global) { + res = dynLink.openLibraryGlobal(path, DEBUG); + } else { + res = dynLink.openLibraryLocal(path, DEBUG); + } + } catch (Throwable t1) { + if( DEBUG ) { + System.err.println("NativeLibrary.open: Catched "+t1.getClass().getSimpleName()+": "+t1.getMessage()); + String errstr; + try { + errstr = dynLink.getLastError(); + } catch (Throwable t2) { errstr=null; } + System.err.println("NativeLibrary.open: Last error "+errstr); + t1.printStackTrace(); + } + res = 0; } if (res != 0) { return new NativeLibrary(res, path, global); @@ -200,7 +213,7 @@ public class NativeLibrary implements DynamicLookupHelper { } if (DEBUG) { - System.err.println("NativeLibrary.open(): Did not succeed in loading (" + windowsLibName + ", " + unixLibName + ", " + macOSXLibName + ")"); + System.err.println("NativeLibrary.open(global "+global+"): Did not succeed in loading (" + windowsLibName + ", " + unixLibName + ", " + macOSXLibName + ")"); } // For now, just return null to indicate the open operation didn't diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java index e4cdbda..7675977 100644 --- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -71,5 +71,8 @@ public class UnixDynamicLinkerImpl implements DynamicLinker { public void closeLibrary(long libraryHandle) { dlclose(libraryHandle); } - + + public String getLastError() { + return dlerror(); + } } diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java index 17d4adc..884ac39 100644 --- a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -66,4 +66,9 @@ public class WindowsDynamicLinkerImpl implements DynamicLinker { FreeLibrary(libraryHandle); } + public String getLastError() { + final int err = GetLastError(); + return "Last error: 0x"+Integer.toHexString(err)+" ("+err+")"; + } + } |