53{
54 if (path.empty())
55 {
56 throw std::runtime_error{"Backend library does not defined"};
57 }
58
59 void *handle;
60 BackendPlugin::Entry
entry;
61
62
63
64
65
66
67
68
69 handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
70 if (handle == nullptr)
71 {
72 std::cerr << dlerror() << std::endl;
73 exit(1);
74 }
75
77 entry =
reinterpret_cast<BackendPlugin::Entry
>(dlsym(handle,
"make_backend"));
78 if ((error = dlerror()) != nullptr)
79 {
80 dlclose(handle);
81 std::cerr <<
error << std::endl;
82 exit(1);
83 }
84
85 return std::make_unique<BackendPlugin>(handle,
entry);
86}
int entry(const int argc, char **argv)