Experimentation with OpenSSL and QT configuration on Windows

Building OpenSSL 1.1.1q with custom installation directory

Run the following commands with x64 Native Tools Command Prompt for VS 2022:

set PATH=%PATH%;C:\dev\PFiles\Strawberry\perl\bin
set PATH=%PATH%;C:\dev\PFiles\nasm-2.15.05
set MY_INSTALL_DIR=C:/dev/libs/OpenSSL
perl Configure VC-WIN64A --prefix="%MY_INSTALL_DIR%" --openssldir="%MY_INSTALL_DIR%"
**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
set CL=/MP
nmake
nmake install

By default OpenSSL builds both DLLs and LIBs and that is what QT probably requires, at least I tried to build OpenSSL with no-shared option as follows:

perl Configure VC-WIN64A --prefix="%MY_INSTALL_DIR%" --openssldir="%MY_INSTALL_DIR%" no-shared

and got the configuration error in QT:

CMake Error at qtbase/cmake/QtBuildInformation.cmake:414 (message):
  Feature "openssl": Forcing to "ON" breaks its condition:

      QT_FEATURE_openssl_runtime OR QT_FEATURE_openssl_linked

  Condition values dump:

      QT_FEATURE_openssl_runtime = "OFF"
      QT_FEATURE_openssl_linked = "OFF"

Building OpenSSL 1.1.1q with default directory

set PATH=%PATH%;C:\dev\PFiles\Strawberry\perl\bin
set PATH=%PATH%;C:\dev\PFiles\nasm-2.15.05
perl Configure VC-WIN64A
set CL=/MP
nmake
nmake install

Building QT 6.3.1 (attempt 1)

configure.bat -prefix %MY_INSTALL_PATH% -DQT_NO_EXCEPTIONS=1 -debug-and-release -force-debug-info -platform win32-msvc -opensource -confirm-license ^
-c++std c++20 -static -I "C:/Program Files/OpenSSL/include" -L "C:/Program Files/OpenSSL/lib" ^
  -skip qt3d -skip qt5compat -skip qtactiveqt -skip qtcharts -skip qtcoap -skip qtconnectivity ^
  -skip qtdatavis3d -skip qtdoc -skip qtlottie -skip qtmqtt -skip qtnetworkauth -skip qtopcua ^
  -skip qtserialport -skip qtpositioning -skip qtquicktimeline -skip qtquick3d -skip qtremoteobjects ^
  -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtvirtualkeyboard -skip qtwayland ^
  -skip qtwebchannel -skip qtwebengine -skip qtwebview
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ no
  OpenSSL 1.1 ............................ yes

Building QT 6.3.1 (attempt 2)

Run the following commands with Windows Command Prompt:

"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64

set "CMAKE_ROOT=C:\dev\PFiles\cmake-3.24.0-rc4-windows-x86_64\bin"
set "NINJA_ROOT=C:\dev\PFiles\ninja-win"
set "PERL_ROOT=C:\dev\PFiles\Strawberry\perl\bin"

set PATH=%CMAKE_ROOT%;%PATH%
set PATH=%NINJA_ROOT%;%PATH%
set PATH=%PERL_ROOT%;%PATH%
set PATH=C:\dev\PFiles\Python35;%PATH%

rem Check if the tools are in PATH
where perl.exe
where python.exe
where cmake.exe
where ninja.exe

set "MY_INSTALL_PATH=C:/dev/libs/Qt6.3.1/windows"
set CL=/MP

configure.bat -prefix %MY_INSTALL_PATH% -DQT_NO_EXCEPTIONS=1 -debug-and-release -force-debug-info -platform win32-msvc -opensource -confirm-license ^
-c++std c++20 -static -I "C:/dev/libs/OpenSSL/include" -L "C:/dev/libs/OpenSSL/lib" ^
  -skip qt3d -skip qt5compat -skip qtactiveqt -skip qtcharts -skip qtcoap -skip qtconnectivity ^
  -skip qtdatavis3d -skip qtdoc -skip qtlottie -skip qtmqtt -skip qtnetworkauth -skip qtopcua ^
  -skip qtserialport -skip qtpositioning -skip qtquicktimeline -skip qtquick3d -skip qtremoteobjects ^
  -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtvirtualkeyboard -skip qtwayland ^
  -skip qtwebchannel -skip qtwebengine -skip qtwebview
cmake --build . --parallel
ninja install

if I add -openssl-linked option I get:

-- Could NOT find Qt6WebSockets (missing: Qt6WebSockets_DIR)
CMake Warning at qtbase/lib/cmake/Qt6/Qt6Config.cmake:263 (message):
  Failed to find Qt component "WebSockets".

  Expected Config file at
  "C:/dev/repos/qt-everywhere-src-6.3.1/qtbase/lib/cmake/Qt6WebSockets/Qt6WebSocketsConfig.cmake"
  does NOT exist

Call Stack (most recent call first):
  qtmqtt/CMakeLists.txt:14 (find_package)

or

CMake Warning at qtbase/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package):
  Found package configuration file:

    C:/dev/repos/qt-everywhere-src-6.3.1/qtbase/lib/cmake/Qt6WebSockets/Qt6WebSocketsConfig.cmake

  but it set Qt6WebSockets_FOUND to FALSE so package "Qt6WebSockets" is
  considered to be NOT FOUND.  Reason given by package:

  Target "Qt6::WebSockets" was not found.  Possibly due to
  QT_NO_CREATE_TARGETS being set to TRUE and thus
  C:/dev/repos/qt-everywhere-src-6.3.1/qtbase/lib/cmake/Qt6WebSockets/Qt6WebSocketsTargets.cmake
  was not included to define the target.

Call Stack (most recent call first):
  qtmqtt/CMakeLists.txt:14 (find_package)


CMake Warning at qtbase/lib/cmake/Qt6/Qt6Config.cmake:263 (message):
  Failed to find Qt component "WebSockets".

  Expected Config file at
  "C:/dev/repos/qt-everywhere-src-6.3.1/qtbase/lib/cmake/Qt6WebSockets/Qt6WebSocketsConfig.cmake"
  exists

Call Stack (most recent call first):
  qtmqtt/CMakeLists.txt:14 (find_package)

1 Response to Experimentation with OpenSSL and QT configuration on Windows

  1. Anton K. says:

    As an option instead of building OpenSSL for Windows you can grab pre-build binaries along with headers from https://slproweb.com/products/Win32OpenSSL.html

Leave a Reply

Your email address will not be published.