Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93951

Windows OpenSSL library dll not found in runtime directory

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.10
    • Core: Other
    • None
    • windows 64 bits

    • Windows

    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.

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            ebeuque Eric Beuque
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes