ENH: more stringent check before adding 'lib' prefix (OSspecific)

- only prefix 'lib' for names without a path

STYLE: add more OSspecific debug output for library loading
This commit is contained in:
Mark Olesen 2019-07-26 14:50:00 +02:00 committed by Andrew Heather
parent 6789e7477b
commit 1ccddd04ef
2 changed files with 32 additions and 2 deletions

View File

@ -1197,11 +1197,23 @@ void* Foam::dlOpen(const fileName& libName, const bool check)
void* handle = ::LoadLibrary(libso.c_str());
if (!handle && !libso.startsWith("lib"))
if
(
!handle
&& libName.find('/') == std::string::npos
&& !libso.startsWith("lib")
)
{
// Try with 'lib' prefix
libso = "lib" + libso;
handle = ::LoadLibrary(libso.c_str());
if (MSwindows::debug)
{
std::cout
<< "dlOpen(const fileName&)"
<< " : dlopen of " << libso << std::endl;
}
}
if (handle)

View File

@ -1670,11 +1670,22 @@ void* Foam::dlOpen(const fileName& libName, const bool check)
{
fileName libso;
if (!libName.startsWith("lib"))
if
(
libName.find('/') == std::string::npos
&& !libName.startsWith("lib")
)
{
// Try with 'lib' prefix
libso = "lib" + libName;
handle = ::dlopen(libso.c_str(), ldflags);
if (POSIX::debug)
{
std::cout
<< "dlOpen(const fileName&)"
<< " : dlopen of " << libso << std::endl;
}
}
else
{
@ -1687,6 +1698,13 @@ void* Foam::dlOpen(const fileName& libName, const bool check)
{
libso = libso.lessExt().ext(EXT_SO);
handle = ::dlopen(libso.c_str(), ldflags);
if (POSIX::debug)
{
std::cout
<< "dlOpen(const fileName&)"
<< " : dlopen of " << libso << std::endl;
}
}
}