Skip to content

Commit

Permalink
try again with LoadLibrary if LoadLibraryExA failed, for #759
Browse files Browse the repository at this point in the history
  • Loading branch information
svigerske committed Apr 19, 2024
1 parent 3d40cc0 commit 9a36a9e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/Common/IpLibraryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ 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( libhandle == NULL )
{
std::stringstream s;
s << "Error " << GetLastError() << " while loading DLL " << libname << ": ";
addLastError(s);
THROW_EXCEPTION(DYNAMIC_LIBRARY_FAILURE, s.str());
}
if( libhandle != NULL )
return;

std::stringstream s;
s << "Error " << GetLastError() << " while loading DLL " << libname << " with LoadLibraryExA: ";
addLastError(s);

libhandle = (void*)LoadLibrary(libname.c_str());

if( libhandle != NULL )
return;

s << "; Error " << GetLastError() << " while loading DLL " << libname << " with LoadLibrary: ";
addLastError(s);

THROW_EXCEPTION(DYNAMIC_LIBRARY_FAILURE, s.str());

#elif defined(HAVE_DLFCN_H)
// ToDo switch to RTLD_LAZY for performance?
Expand Down

0 comments on commit 9a36a9e

Please sign in to comment.