From 1ee821ec62d0adf1fc6132a1cf853d3af0467908 Mon Sep 17 00:00:00 2001 From: Tina Zhang Date: Fri, 25 Jul 2014 10:13:53 +0800 Subject: Support dynamic lib name without ".dylib" on Mac On Mac, some of the dynamic libs has name without ".dylib". Like, "System/Library/Frameworks/OpenGL.framework/OpenGL", we need solution to handle it in the dlopen() API. Change-Id: Ie513ace5a0d7d154f73e0f13919005d1498901d7 Signed-off-by: Tina Zhang Signed-off-by: Chao Qin --- emulator/opengl/shared/emugl/common/shared_library.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'emulator/opengl/shared/emugl/common/shared_library.cpp') diff --git a/emulator/opengl/shared/emugl/common/shared_library.cpp b/emulator/opengl/shared/emugl/common/shared_library.cpp index db1c75c..e78e36b 100644 --- a/emulator/opengl/shared/emugl/common/shared_library.cpp +++ b/emulator/opengl/shared/emugl/common/shared_library.cpp @@ -75,7 +75,17 @@ SharedLibrary* SharedLibrary::open(const char* libraryName) { libPath = path; } +#ifdef __APPLE__ + // On OSX, some libraries don't include an extension (notably OpenGL) + // On OSX we try to open |libraryName| first. If that doesn't exist, + // we try |libraryName|.dylib + void* lib = dlopen(libraryName, RTLD_NOW); + if (lib == NULL) { + lib = dlopen(libPath, RTLD_NOW); + } +#else void* lib = dlopen(libPath, RTLD_NOW); +#endif if (path) { free(path); -- cgit v1.1