Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.10
-
None
-
windows 64 bits
Description
I have a project using Qt with OpenSSL for QSslSocket.
So my project has dependencies to the libcrypto-1_1-x64.dll and libssl-1_1-x64.dll.
Regarding the sources code of QSystemLibrary::load function
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */) { QStringList searchOrder;#if !defined(QT_BOOTSTRAPPED) if (!onlySystemDirectory) searchOrder << QFileInfo(qAppFileName()).path(); #endif searchOrder << qSystemDirectory(); if (!onlySystemDirectory) { const QString PATH = QString::fromWCharArray((const wchar_t *)_wgetenv(L"PATH")); searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts); } const QString fileName = QString::fromWCharArray(libraryName) + QLatin1String(".dll"); // Start looking in the order specified for (int i = 0; i < searchOrder.count(); ++i) { QString fullPathAttempt = searchOrder.at(i); if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) fullPathAttempt.append(QLatin1Char('\\')); fullPathAttempt.append(fileName); HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16()); if (inst != 0) return inst; } return 0; }
The DLL can be found if present in the same path than the executable, or if in any dir in PATH.
With some IDE like CLion in debug mode, executable can be in a different path than the runtime path set.
For example, we can have following structure :
- src/
- build/myprogram.exe
- runtime/libcrypto-1_1-x64.dll
- runtime/libssl-1_1-x64.dll.
- runtime/Qt5Cored.dll.
- runtime/Qt5Networkd.dll.
If we call ../build/myprogram.exe when we are in the runtime/ directory, Qt's dll are found but not OpenSSL dll.
I think that QSystemLibrary::load should add in it's search path the current directory "." or add a mecanism to add custom path programmatically without changing the PATH variable.
Regards.