comparison Plugins/Engine/SharedLibrary.cpp @ 2364:ae50eccd41b7

compilation succeeds on OpenBSD
author jodogne
date Mon, 21 Aug 2017 16:28:53 +0200
parents a3a65de1840f
children 878b59270859
comparison
equal deleted inserted replaced
2363:f8ef157f2d73 2364:ae50eccd41b7
44 44
45 #include <boost/filesystem.hpp> 45 #include <boost/filesystem.hpp>
46 46
47 #if defined(_WIN32) 47 #if defined(_WIN32)
48 #include <windows.h> 48 #include <windows.h>
49 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 49 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
50 #include <dlfcn.h> 50 #include <dlfcn.h>
51 #else 51 #else
52 #error Support your platform here 52 #error Support your platform here
53 #endif 53 #endif
54 54
64 { 64 {
65 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError(); 65 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError();
66 throw OrthancException(ErrorCode_SharedLibrary); 66 throw OrthancException(ErrorCode_SharedLibrary);
67 } 67 }
68 68
69 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 69 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
70 handle_ = ::dlopen(path_.c_str(), RTLD_NOW); 70 handle_ = ::dlopen(path_.c_str(), RTLD_NOW);
71 if (handle_ == NULL) 71 if (handle_ == NULL)
72 { 72 {
73 std::string explanation; 73 std::string explanation;
74 const char *tmp = ::dlerror(); 74 const char *tmp = ::dlerror();
90 { 90 {
91 if (handle_) 91 if (handle_)
92 { 92 {
93 #if defined(_WIN32) 93 #if defined(_WIN32)
94 ::FreeLibrary((HMODULE)handle_); 94 ::FreeLibrary((HMODULE)handle_);
95 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 95 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
96 ::dlclose(handle_); 96 ::dlclose(handle_);
97 #else 97 #else
98 #error Support your platform here 98 #error Support your platform here
99 #endif 99 #endif
100 } 100 }
108 throw OrthancException(ErrorCode_InternalError); 108 throw OrthancException(ErrorCode_InternalError);
109 } 109 }
110 110
111 #if defined(_WIN32) 111 #if defined(_WIN32)
112 return ::GetProcAddress((HMODULE)handle_, name.c_str()); 112 return ::GetProcAddress((HMODULE)handle_, name.c_str());
113 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 113 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
114 return ::dlsym(handle_, name.c_str()); 114 return ::dlsym(handle_, name.c_str());
115 #else 115 #else
116 #error Support your platform here 116 #error Support your platform here
117 #endif 117 #endif
118 } 118 }