| 24 | namespace dali { |
| 25 | |
| 26 | void PluginManager::LoadLibrary(const std::string& lib_path, bool global_symbols, bool allow_fail) { |
| 27 | // dlopen is thread safe |
| 28 | int flags = global_symbols ? RTLD_GLOBAL : RTLD_LOCAL; |
| 29 | flags |= RTLD_LAZY; |
| 30 | LOG_LINE << "Loading " << lib_path << "\n"; |
| 31 | auto handle = dlopen(lib_path.c_str(), flags); |
| 32 | if (handle == nullptr) { |
| 33 | std::string err_msg = |
| 34 | std::string("Failed to load library ") + lib_path + ": " + std::string(dlerror()); |
| 35 | if (allow_fail) { |
| 36 | std::cerr << err_msg << "\n"; |
| 37 | } else { |
| 38 | DALI_FAIL(err_msg); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | inline const std::string& DefaultPluginPath() { |
| 44 | static const std::string path = [&]() -> std::string { |