Skip to content

Commit

Permalink
use LoadLibraryExA for absolute paths to libs only
Browse files Browse the repository at this point in the history
- LoadLibraryExA with relative path and LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
  gives an incorrect parameter error
- LoadLibraryExA with relative path and LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
  does not look into standard search paths like PATH
- thus use LoadLibraryA again when libname seems to be relative path
- fixes #759
  • Loading branch information
svigerske committed Apr 22, 2024
1 parent 5a0daef commit eaf02be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ More detailed information about incremental changes can be found in the

## 3.14

### 3.14.16 (2024-04-22)

- Fixed load of linear solver libraries at runtime on Windows, which got
broken for relative paths (the default) in 3.14.15 [#759].

### 3.14.15 (2024-04-10)

- Fixed include guard of IpGenAugSystemSolver.hpp [#756, by Christopher Wellons].
Expand Down
9 changes: 8 additions & 1 deletion src/Common/IpLibraryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ void LibraryLoader::loadLibrary()
}

#ifdef HAVE_WINDOWS_H
libhandle = (void*)LoadLibraryExA(libname.c_str(), NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
/* if absolute path, then use LoadLibraryExA with LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR to find
* dependencies of library in same directory
* otherwise, use standard search paths (which includes PATH)
*/
if( libname.length() > 2 && libname[1] == ':' )
libhandle = (void*)LoadLibraryExA(libname.c_str(), NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
else
libhandle = (void*)LoadLibraryA(libname.c_str());

if( libhandle == NULL )
{
Expand Down

0 comments on commit eaf02be

Please sign in to comment.