CVB++ 15.0
detail_dyn_loader_linux.hpp
1#pragma once
2
3#include <vector>
4
5#include "../global.hpp"
6#include "../string.hpp"
7
8#include "detail_dyn_loader.hpp"
9
10#include <dlfcn.h>
11
12namespace Cvb
13{
14
15 CVB_BEGIN_INLINE_NS
16
17 namespace Internal
18 {
19
20 inline DynLoader::DynLoader(const String &name)
21 {
22 auto fileName = CVB_LIT("lib") + name + CVB_LIT(".so");
23 handle_ = dlopen(fileName.c_str(), RTLD_NOW);
24 if (!handle_)
25 throw std::runtime_error("failed to load module");
26 }
27
28 inline DynLoader::~DynLoader()
29 {
30 dlclose(handle_);
31 }
32
33 inline void *DynLoader::LoadSymbol(const String &name) noexcept
34 {
35 return dlsym(handle_, name.c_str());
36 }
37
38 } // namespace Internal
39
40 CVB_END_INLINE_NS
41
42} // namespace Cvb
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49