diff --git a/onnxruntime/core/platform/windows/env.cc b/onnxruntime/core/platform/windows/env.cc index 17a4545a97..e00ad5ddbe 100644 --- a/onnxruntime/core/platform/windows/env.cc +++ b/onnxruntime/core/platform/windows/env.cc @@ -447,7 +447,7 @@ class WindowsEnv : public Env { } virtual Status LoadDynamicLibrary(const std::string& library_filename, void** handle) const override { - *handle = ::LoadLibraryExA(library_filename.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); + *handle = ::LoadLibraryExA(library_filename.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); if (!*handle) return common::Status(common::ONNXRUNTIME, common::FAIL, "Failed to load library"); return common::Status::OK(); diff --git a/onnxruntime/test/shared_lib/test_inference.cc b/onnxruntime/test/shared_lib/test_inference.cc index 09dd036f4c..7a85b1f081 100644 --- a/onnxruntime/test/shared_lib/test_inference.cc +++ b/onnxruntime/test/shared_lib/test_inference.cc @@ -346,15 +346,11 @@ TEST(CApiTest, DISABLED_test_custom_op_library) { std::string lib_name; #if defined(_WIN32) - char current_directory[/*MAX_PATH*/ 260]; - if (_getcwd(current_directory, _countof(current_directory))) - lib_name = current_directory; - lib_name += "\\custom_op_library.dll"; - + lib_name = "custom_op_library.dll"; #elif defined(__APPLE__) lib_name = "libcustom_op_library.dylib"; #else -lib_name = "./libcustom_op_library.so"; + lib_name = "./libcustom_op_library.so"; #endif TestInference(*ort_env, CUSTOM_OP_LIBRARY_TEST_MODEL_URI, inputs, "output", expected_dims_y, expected_values_y, 0, nullptr, lib_name.c_str());