Mercurial > hg > orthanc
comparison Plugins/Engine/SharedLibrary.cpp @ 1026:a13ccd93df28
fix OS X build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Jul 2014 12:18:40 +0200 |
parents | f57802f8b4dc |
children | 57400f233de8 |
comparison
equal
deleted
inserted
replaced
1025:da2226739305 | 1026:a13ccd93df28 |
---|---|
34 | 34 |
35 #include "../../Core/Toolbox.h" | 35 #include "../../Core/Toolbox.h" |
36 | 36 |
37 #if defined(_WIN32) | 37 #if defined(_WIN32) |
38 #include <windows.h> | 38 #include <windows.h> |
39 #elif defined(__linux) | 39 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
40 #include <dlfcn.h> | 40 #include <dlfcn.h> |
41 #else | 41 #else |
42 #error Support your platform here | 42 #error Support your platform here |
43 #endif | 43 #endif |
44 | 44 |
56 { | 56 { |
57 LOG(ERROR) << "LoadLibrary(" << path << ") failed: Error " << ::GetLastError(); | 57 LOG(ERROR) << "LoadLibrary(" << path << ") failed: Error " << ::GetLastError(); |
58 throw OrthancException(ErrorCode_SharedLibrary); | 58 throw OrthancException(ErrorCode_SharedLibrary); |
59 } | 59 } |
60 | 60 |
61 #elif defined(__linux) | 61 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
62 handle_ = ::dlopen(path.c_str(), RTLD_NOW); | 62 handle_ = ::dlopen(path.c_str(), RTLD_NOW); |
63 if (handle_ == NULL) | 63 if (handle_ == NULL) |
64 { | 64 { |
65 std::string explanation; | 65 std::string explanation; |
66 const char *tmp = ::dlerror(); | 66 const char *tmp = ::dlerror(); |
82 { | 82 { |
83 if (handle_) | 83 if (handle_) |
84 { | 84 { |
85 #if defined(_WIN32) | 85 #if defined(_WIN32) |
86 ::FreeLibrary((HMODULE)handle_); | 86 ::FreeLibrary((HMODULE)handle_); |
87 #elif defined(__linux) | 87 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
88 ::dlclose(handle_); | 88 ::dlclose(handle_); |
89 #else | 89 #else |
90 #error Support your platform here | 90 #error Support your platform here |
91 #endif | 91 #endif |
92 } | 92 } |
100 throw OrthancException(ErrorCode_InternalError); | 100 throw OrthancException(ErrorCode_InternalError); |
101 } | 101 } |
102 | 102 |
103 #if defined(_WIN32) | 103 #if defined(_WIN32) |
104 return ::GetProcAddress((HMODULE)handle_, name.c_str()); | 104 return ::GetProcAddress((HMODULE)handle_, name.c_str()); |
105 #elif defined(__linux) | 105 #elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) |
106 return ::dlsym(handle_, name.c_str()); | 106 return ::dlsym(handle_, name.c_str()); |
107 #else | 107 #else |
108 #error Support your platform here | 108 #error Support your platform here |
109 #endif | 109 #endif |
110 } | 110 } |