Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 2ddfe7a

Browse files
committed
fix: add dll search path
1 parent 44efcfe commit 2ddfe7a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cortex-cpp/controllers/server.cc

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ constexpr static auto kOnnxEngine = "cortex.onnx";
1919
constexpr static auto kTensorrtLlmEngine = "cortex.tensorrt-llm";
2020
} // namespace
2121

22-
server::server(){
23-
24-
// Some default values for now below
25-
// log_disable(); // Disable the log to file feature, reduce bloat for
26-
// target
27-
// system ()
22+
server::server() {
23+
24+
// Some default values for now below
25+
// log_disable(); // Disable the log to file feature, reduce bloat for
26+
// target
27+
// system ()
28+
#if defined(WIN32)
29+
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
30+
#endif
2831
};
2932

3033
server::~server() {}
@@ -292,6 +295,12 @@ void server::LoadModel(const HttpRequestPtr& req,
292295
(getenv("ENGINE_PATH") ? getenv("ENGINE_PATH")
293296
: cortex_utils::GetCurrentPath()) +
294297
get_engine_path(engine_type);
298+
#if defined(WIN32)
299+
auto ws = std::wstring(abs_path.begin(), abs_path.end());
300+
if(AddDllDirectory(ws.c_str()) == 0) {
301+
LOG_WARN << "Could not add dll directory: " << abs_path;
302+
}
303+
#endif
295304
engines_[engine_type].dl =
296305
std::make_unique<cortex_cpp::dylib>(abs_path, "engine");
297306

0 commit comments

Comments
 (0)