# HG changeset patch # User Sebastien Jodogne # Date 1404987520 -7200 # Node ID a13ccd93df288906d88441d0dbd938202406ca04 # Parent da2226739305c77020b37ce8db679fd73137237c fix OS X build diff -r da2226739305 -r a13ccd93df28 Plugins/Engine/PluginsManager.cpp --- a/Plugins/Engine/PluginsManager.cpp Thu Jul 10 11:54:21 2014 +0200 +++ b/Plugins/Engine/PluginsManager.cpp Thu Jul 10 12:18:40 2014 +0200 @@ -44,6 +44,8 @@ #define PLUGIN_EXTENSION ".dll" #elif defined(__linux) #define PLUGIN_EXTENSION ".so" +#elif defined(__APPLE__) && defined(__MACH__) +#define PLUGIN_EXTENSION ".dylib" #else #error Support your platform here #endif diff -r da2226739305 -r a13ccd93df28 Plugins/Engine/SharedLibrary.cpp --- a/Plugins/Engine/SharedLibrary.cpp Thu Jul 10 11:54:21 2014 +0200 +++ b/Plugins/Engine/SharedLibrary.cpp Thu Jul 10 12:18:40 2014 +0200 @@ -36,7 +36,7 @@ #if defined(_WIN32) #include -#elif defined(__linux) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) #include #else #error Support your platform here @@ -58,7 +58,7 @@ throw OrthancException(ErrorCode_SharedLibrary); } -#elif defined(__linux) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) handle_ = ::dlopen(path.c_str(), RTLD_NOW); if (handle_ == NULL) { @@ -84,7 +84,7 @@ { #if defined(_WIN32) ::FreeLibrary((HMODULE)handle_); -#elif defined(__linux) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) ::dlclose(handle_); #else #error Support your platform here @@ -102,7 +102,7 @@ #if defined(_WIN32) return ::GetProcAddress((HMODULE)handle_, name.c_str()); -#elif defined(__linux) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) return ::dlsym(handle_, name.c_str()); #else #error Support your platform here diff -r da2226739305 -r a13ccd93df28 UnitTestsSources/PluginsTests.cpp --- a/UnitTestsSources/PluginsTests.cpp Thu Jul 10 11:54:21 2014 +0200 +++ b/UnitTestsSources/PluginsTests.cpp Thu Jul 10 12:18:40 2014 +0200 @@ -55,6 +55,13 @@ ASSERT_TRUE(l.HasFunction("dlclose")); ASSERT_FALSE(l.HasFunction("world")); +#elif defined(__APPLE__) && defined(__MACH__) + SharedLibrary l("libdl.dylib"); + ASSERT_THROW(l.GetFunction("world"), OrthancException); + ASSERT_TRUE(l.GetFunction("dlopen") != NULL); + ASSERT_TRUE(l.HasFunction("dlclose")); + ASSERT_FALSE(l.HasFunction("world")); + #else #error Support your platform here #endif