Skip to content

Commit 285e72e

Browse files
committed
mtsManagerLocal: use PATH instead of LD_LIBRARY_PATH for dynamic loading on Windows
1 parent 602c1b3 commit 285e72e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cisstMultiTask/code/mtsManagerLocal.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Author(s): Min Yang Jung
66
Created on: 2009-12-07
77
8-
(C) Copyright 2009-2020 Johns Hopkins University (JHU), All Rights Reserved.
8+
(C) Copyright 2009-2024 Johns Hopkins University (JHU), All Rights Reserved.
99
1010
--- begin cisst license - do not edit ---
1111
@@ -20,6 +20,7 @@ no warranty. The complete license can be found in license.txt and
2020

2121
#include <cisstCommon/cmnThrow.h>
2222
#include <cisstCommon/cmnPath.h>
23+
#include <cisstCommon/cmnPortability.h>
2324
#include <cisstOSAbstraction/osaSleep.h>
2425
#include <cisstOSAbstraction/osaGetTime.h>
2526
#include <cisstOSAbstraction/osaSocket.h>
@@ -905,15 +906,19 @@ mtsComponent * mtsManagerLocal::CreateComponentDynamicallyJSON(const std::string
905906
{
906907
// -1- try to dynamically load the library if specified
907908
if (!sharedLibrary.empty()) {
908-
// create load and path based on LD_LIBRARY_PATH
909+
// create load and path based on LD_LIBRARY_PATH (or PATH on Windows)
909910
osaDynamicLoader loader;
910911
std::string fullPath;
911912
// check if the file already exists, i.e. use provided a full path
912913
if (cmnPath::Exists(sharedLibrary)) {
913914
fullPath = sharedLibrary;
914915
} else {
915916
cmnPath path;
917+
#if (CISST_OS == CISST_WINDOWS)
918+
path.AddFromEnvironment("PATH");
919+
#else
916920
path.AddFromEnvironment("LD_LIBRARY_PATH");
921+
#endif
917922
fullPath = path.Find(cmnPath::SharedLibrary(sharedLibrary));
918923
if (fullPath.empty()) {
919924
fullPath = sharedLibrary;

0 commit comments

Comments
 (0)