## Based on 
## https://github.com/OpenNI/OpenNI2/commit/86efc7a

--- a/ThirdParty/PSCommon/XnLib/Source/Linux/XnLinuxSharedLibs.cpp
+++ b/ThirdParty/PSCommon/XnLib/Source/Linux/XnLinuxSharedLibs.cpp
@@ -34,9 +34,20 @@
 	XN_VALIDATE_INPUT_PTR(cpFileName);
 	XN_VALIDATE_OUTPUT_PTR(pLibHandle);
 
+	// Resolve the file name to the absolute path. This is necessary because
+	// we need to get the absolute path of this library by dladdr() later.
+	// Note dladdr() seems to return the path specified to dlopen() "as it is".
+	XnChar* strAbsoluteFileName = realpath(cpFileName, NULL);
+	if (strAbsoluteFileName == NULL) {
+		// error
+		xnLogWarning(XN_MASK_OS, "Failed to get absolute path for lib: %s\n", cpFileName);
+		return XN_STATUS_OS_CANT_LOAD_LIB;
+	}
+
 	// Load the requested shared library via the OS
-	*pLibHandle = dlopen(cpFileName, RTLD_NOW);
-	
+	*pLibHandle = dlopen(strAbsoluteFileName, RTLD_NOW);
+	free(strAbsoluteFileName); // Don't forget to free the memory allocated by realpath().
+
 	// Make sure it succeeded (return value is not NULL). If not return an error....
 	if (*pLibHandle == NULL)
 	{

