53 const char* customLibPath =
nullptr) {
54 static auto init = std::make_unique<std::once_flag>();
55 static void* (*getProc)(
const char*);
58 init = std::make_unique<std::once_flag>();
63 std::call_once(*init, [customLibPath]() {
65 customLibPath ? customLibPath : std::getenv(
"CPPINTEROP_LIBRARY_PATH");
70 HMODULE h = LoadLibraryA(path);
72 getProc =
reinterpret_cast<void* (*)(
const char*)
>(
73 GetProcAddress(h,
"CppGetProcAddress"));
77 std::cerr <<
"[CppInterOp Dispatch] error code=" << GetLastError()
81 void* handle = dlopen(path, RTLD_LOCAL | RTLD_NOW);
84 getProc =
reinterpret_cast<void* (*)(
const char*)
>(
85 dlsym(handle,
"CppGetProcAddress"));
89 std::cerr <<
"[CppInterOp Dispatch] " << dlerror() <<
"\n";
95 init = std::make_unique<std::once_flag>();
100 return getProc(name);