Commit 8432917d authored by Junfeng Dong's avatar Junfeng Dong Committed by Scott Cyphers

Fix dll library load path on Windows. (#2784)

parent 4ca457e2
......@@ -123,7 +123,7 @@ unique_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
static string find_my_file()
{
#ifdef _WIN32
HMODULE hModule = GetModuleHandleW(NULL);
HMODULE hModule = GetModuleHandleW(L"ngraph.dll");
WCHAR wpath[MAX_PATH];
GetModuleFileNameW(hModule, wpath, MAX_PATH);
wstring ws(wpath);
......@@ -157,6 +157,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
string my_directory = file_util::get_directory(find_my_file());
string library_path = file_util::path_join(my_directory, library_name);
#ifdef _WIN32
SetDllDirectory((LPCSTR)my_directory.c_str());
handle = LoadLibrary(library_path.c_str());
#else
handle = dlopen(library_path.c_str(), RTLD_NOW | RTLD_GLOBAL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment