Print error instead of failing silently when loading plugins

Previously the return value of dlopen was ignored, meaning a failed load of a shared library would stay unnoticed
This commit is contained in:
Philipp Schmutz
2024-10-26 16:22:47 +02:00
parent 078c7bb42e
commit 7cf457286d
+9 -1
View File
@@ -387,7 +387,15 @@ void mj_loadPluginLibrary(const char* path) {
#if defined(_WIN32) || defined(__CYGWIN__)
LoadLibraryA(path);
#else
dlopen(path, RTLD_NOW | RTLD_LOCAL);
void* handle = dlopen(path, RTLD_NOW | RTLD_LOCAL);
if (!handle) {
const char* error = dlerror();
if (error) {
mju_error("Error loading plugin library '%s': %s\n", path, error);
} else {
mju_error("Unknown error loading plugin library '%s'\n", path);
}
}
#endif
}