! * \brief Create a platform specific handle to a loaded dynamic library * \details Calls platform specific code to load a dynamic library and create a handle for it * \param[in] libPrefix Prefix to be appended on linux style OS's * \param[in] libraryName Name of the library of interest * \param[in] quiet Print error information to the CONSOLE if true * * \returns Platform specific library hand
| 45 | * |
| 46 | */ |
| 47 | inline void* LoadSharedLibrary( const std::string& libPrefix, std::string libraryName, bool quiet ) |
| 48 | { |
| 49 | #if defined( _WIN32 ) |
| 50 | libraryName += ".dll"; |
| 51 | |
| 52 | // HMODULE is actually the load address; function returns NULL if it cannot find the shared library |
| 53 | HMODULE fileHandle = ::LoadLibraryExA(libraryName.c_str(), NULL, NULL); |
| 54 | #elif defined(__linux__) |
| 55 | std::string linuxName = libPrefix; |
| 56 | linuxName += libraryName += ".so"; |
| 57 | void* fileHandle = ::dlopen( linuxName.c_str( ), RTLD_NOW ); |
| 58 | if( !quiet && !fileHandle ) |
| 59 | { |
| 60 | std::cerr << ::dlerror( ) << std::endl; |
| 61 | } |
| 62 | #elif defined(__APPLE__) |
| 63 | std::string appleName = libPrefix; |
| 64 | appleName += libraryName += ".dylib"; |
| 65 | void* fileHandle = ::dlopen( appleName.c_str( ), RTLD_NOW ); |
| 66 | if( !quiet && !fileHandle ) |
| 67 | { |
| 68 | std::cerr << ::dlerror( ) << std::endl; |
| 69 | } |
| 70 | #else |
| 71 | #error "unsupported platform" |
| 72 | #endif |
| 73 | |
| 74 | return fileHandle; |
| 75 | } |
| 76 | |
| 77 | /*! |
| 78 | * \brief Release the handle to the dynamic library |
no outgoing calls
no test coverage detected