From 285e72e552587170b847d336f535fe9837d0aa83 Mon Sep 17 00:00:00 2001 From: Peter Kazanzides Date: Sun, 10 Nov 2024 12:25:25 -0500 Subject: [PATCH] mtsManagerLocal: use PATH instead of LD_LIBRARY_PATH for dynamic loading on Windows --- cisstMultiTask/code/mtsManagerLocal.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cisstMultiTask/code/mtsManagerLocal.cpp b/cisstMultiTask/code/mtsManagerLocal.cpp index eda63d581..ea1136c29 100644 --- a/cisstMultiTask/code/mtsManagerLocal.cpp +++ b/cisstMultiTask/code/mtsManagerLocal.cpp @@ -5,7 +5,7 @@ Author(s): Min Yang Jung Created on: 2009-12-07 - (C) Copyright 2009-2020 Johns Hopkins University (JHU), All Rights Reserved. + (C) Copyright 2009-2024 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- @@ -20,6 +20,7 @@ no warranty. The complete license can be found in license.txt and #include #include +#include #include #include #include @@ -905,7 +906,7 @@ mtsComponent * mtsManagerLocal::CreateComponentDynamicallyJSON(const std::string { // -1- try to dynamically load the library if specified if (!sharedLibrary.empty()) { - // create load and path based on LD_LIBRARY_PATH + // create load and path based on LD_LIBRARY_PATH (or PATH on Windows) osaDynamicLoader loader; std::string fullPath; // check if the file already exists, i.e. use provided a full path @@ -913,7 +914,11 @@ mtsComponent * mtsManagerLocal::CreateComponentDynamicallyJSON(const std::string fullPath = sharedLibrary; } else { cmnPath path; +#if (CISST_OS == CISST_WINDOWS) + path.AddFromEnvironment("PATH"); +#else path.AddFromEnvironment("LD_LIBRARY_PATH"); +#endif fullPath = path.Find(cmnPath::SharedLibrary(sharedLibrary)); if (fullPath.empty()) { fullPath = sharedLibrary;