45 std::vector<std::string> paths;
49 if (
const char *e = std::getenv(opt.
env_var.c_str()))
50 if (e && *e)
51 paths.emplace_back(e);
53 auto add_dirs = [&](const char *env) {
54 if (!env)
55 return;
56 std::string s(env);
57 size_t i = 0;
58 while (i < s.size()) {
59 const auto j = s.find(':', i);
60 const auto dir = s.substr(i, j == std::string::npos ? j : j - i);
61 if (!dir.empty())
62 paths.push_back(dir +
"/" + opt.
library);
63 if (j == std::string::npos)
64 break;
65 i = j + 1;
66 }
67 };
68 add_dirs(std::getenv("EON_POTENTIALS_PATH"));
69
70 std::string last_dlerr;
71 for (const auto &p : paths) {
72 m_lib = open_lib(p.c_str());
74 break;
75#ifndef _WIN32
76 if (const char *e = dlerror())
77 last_dlerr = e;
78#endif
79 }
81 std::string msg =
82 "RGPOT(" +
m_tag +
"): " + opt.
library +
" not found (set " +
84 " or EON_POTENTIALS_PATH)";
85 if (!last_dlerr.empty())
86 msg += std::string("; last dlerror: ") + last_dlerr;
87 throw std::runtime_error(msg);
88 }
89
90 auto abi =
91 reinterpret_cast<int (*)()
>(load_sym(
m_lib,
"rgpot_engine_abi_version"));
93 reinterpret_cast<create_fn>(load_sym(
m_lib,
"rgpot_engine_create"));
101 throw std::runtime_error(
"RGPOT(" +
m_tag +
102 "): engine C ABI missing/mismatch");
103 }
104 char err[1024]{};
109 throw std::runtime_error(
"RGPOT(" +
m_tag +
110 "): create failed: " + std::string(err));
111 }
112}
void(*)(RgpotEnginePot *) destroy_fn
int(*)(RgpotEnginePot *, long, const double *, const int *, double *, double *, double *, const double *, rgpot_engine_coord_transform, void *) force_fn
RgpotEnginePot *(*)(const void *, size_t, char *, size_t) create_fn
#define RGPOT_ENGINE_ABI_VERSION
std::string tag
Backend tag for error messages ("uma", ...).
std::string env_var
Optional env var naming an explicit .so path (checked first).
std::vector< unsigned char > config
Cap'n Proto flat-array message (the engine's params struct on the shared Potentials....
std::string engine_path
Optional explicit .so path from config.
std::string library
Library basename to search for, e.g. "libuma_engine.so".