Build QT Source with OpenSSL and MSVC2017

build qt from source windows
qt openssl
qt msvc
qt static build msvc
qt msvc compiler
qt build from source debug

I managed to compile openssl-1.0.2o (using nasm-2.13.03) like shown here: https://wiki.qt.io/Building_Qt_Desktop_for_Windows_with_MSVC

However trying to build the Qt-Source already fails when trying to configure using the following command (it works without ssl/openssl):

C:/qt-everywhere-src-5.11.1/configure -platform win32-msvc2017 -prefix win32-msvc2017 -opensource -confirm-license -debug-and-release -force-debug-info -nomake examples -nomake tests -skip qtwebengine -skip qt3d -I C:\openssl-1.0.2o\out32dll -L C:\openssl-1.0.2o\out32dll -ssl -openssl

with the following Error in command line:

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

ERROR: Feature 'openssl' was enabled, but the pre-condition '!features.securetransport && (features.openssl-linked || libs.openssl_headers)' failed.

ERROR: Feature 'ssl' was enabled, but the pre-condition 'config.winrt || features.securetransport || features.openssl' failed.

the config.log reveals it fails because of an "alloca.h"

 Command line: -platform win32-msvc2017 -prefix win32-msvc -opensource -confirm-license -debug-and-release -force-debug-info -nomake examples -nomake tests -skip qtwebengine -skip qt3d -I C:\openssl-1.0.2o\out32dll -L C:\openssl-1.0.2o\out32dll -ssl -openssl
loaded result for config test config.qtbase.tests.verifyspec
+ cd /d C:\qt_build\config.tests\verifyspec && C:\qt_build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl-1.0.2o\\out32dll" "INCLUDEPATH += C:\\openssl-1.0.2o\\out32dll" C:/Entwicklung/qt-everywhere-src-5.11.1/qtbase/config.tests/verifyspec
+ cd /d C:\qt_build\config.tests\verifyspec && set MAKEFLAGS=& jom clean && set MAKEFLAGS=& jom
> jom 1.1.2 - empower your cores
>   del verifyspec.obj
>   del verifyspec.exp verifyspec.vc.pdb verifyspec.ilk verifyspec.idb
> C:\qt_build\config.tests\verifyspec\verifyspec.exp konnte nicht gefunden werden
> jom 1.1.2 - empower your cores
>   cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdverifyspec.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -IC:\qt-everywhere-src-5.11.1\qtbase\config.tests\verifyspec -I. -IC:\openssl-1.0.2o\out32dll -IC:\qt-everywhere-src-5.11.1\qtbase\mkspecs\win32-msvc -Fo @C:\Users\msrei\AppData\Local\Temp\verifyspec.obj.5420.0.jom
> verifyspec.cpp
>   link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:verifyspec.exe @C:\Users\msrei\AppData\Local\Temp\verifyspec.exe.5420.328.jom
test config.qtbase.tests.verifyspec succeeded
loaded result for config test config.qtbase.tests.architecture
+ cd /d C:\qt_build\config.tests\arch && C:\qt_build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl-1.0.2o\\out32dll" "INCLUDEPATH += C:\\openssl-1.0.2o\\out32dll" C:/Entwicklung/qt-everywhere-src-5.11.1/qtbase/config.tests/arch
+ cd /d C:\qt_build\config.tests\arch && set MAKEFLAGS=& jom clean && set MAKEFLAGS=& jom
> jom 1.1.2 - empower your cores
>   del arch.obj
>   del arch.exp arch.vc.pdb arch.ilk arch.idb
> C:\qt_build\config.tests\arch\arch.exp konnte nicht gefunden werden
> jom 1.1.2 - empower your cores
>   cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdarch.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -IC:\qt-everywhere-src-5.11.1\qtbase\config.tests\arch -I. -IC:\openssl-1.0.2o\out32dll -IC:\qt-everywhere-src-5.11.1\qtbase\mkspecs\win32-msvc -Fo @C:\Users\msrei\AppData\Local\Temp\arch.obj.12860.0.jom
> arch.cpp
>   link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:arch.exe @C:\Users\msrei\AppData\Local\Temp\arch.exe.12860.94.jom
Detected architecture: i386 (sse sse2)
test config.qtbase.tests.architecture gave result i386
loaded result for config test config.qtbase.tests.sse2
+ cd /d C:\qt_build\config.tests\x86_simd && C:\qt_build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl-1.0.2o\\out32dll" "INCLUDEPATH += C:\\openssl-1.0.2o\\out32dll" "CONFIG+=add_cflags" "DEFINES+=NO_ATTRIBUTE" "SIMD=sse2" C:/Entwicklung/qt-everywhere-src-5.11.1/qtbase/config.tests/x86_simd
+ cd /d C:\qt_build\config.tests\x86_simd && set MAKEFLAGS=& jom clean && set MAKEFLAGS=& jom
> jom 1.1.2 - empower your cores
>   del main.obj
>   del x86_simd.exp x86_simd.vc.pdb x86_simd.ilk x86_simd.idb
> C:\qt_build\config.tests\x86_simd\x86_simd.exp konnte nicht gefunden werden
> jom 1.1.2 - empower your cores
>   cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -arch:SSE2 -Zi -MDd -W0 -EHsc /Fdx86_simd.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DNO_ATTRIBUTE -DQT_COMPILER_SUPPORTS_SSE2 -IC:\qt-everywhere-src-5.11.1\qtbase\config.tests\x86_simd -I. -IC:\openssl-1.0.2o\out32dll -IC:\qt-everywhere-src-5.11.1\qtbase\mkspecs\win32-msvc -Fo @C:\Users\msrei\AppData\Local\Temp\main.obj.11032.0.jom
> main.cpp
>   link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:x86_simd.exe @C:\Users\msrei\AppData\Local\Temp\x86_simd.exe.11032.109.jom
test config.qtbase.tests.sse2 succeeded
loaded result for config test config.qtbase.tests.aesni
+ cd /d C:\qt_build\config.tests\x86_simd && C:\qt_build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl-1.0.2o\\out32dll" "INCLUDEPATH += C:\\openssl-1.0.2o\\out32dll" "CONFIG+=add_cflags" "DEFINES+=NO_ATTRIBUTE" "SIMD=aesni" C:/Entwicklung/qt-everywhere-src-5.11.1/qtbase/config.tests/x86_simd
+ cd /d C:\qt_build\config.tests\x86_simd && set MAKEFLAGS=& jom clean && set MAKEFLAGS=& jom
> jom 1.1.2 - empower your cores
>   del main.obj
>   del x86_simd.exp x86_simd.vc.pdb x86_simd.ilk x86_simd.idb
> jom 1.1.2 - empower your cores
>   cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -arch:SSE2 -Zi -MDd -W0 -EHsc /Fdx86_simd.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DNO_ATTRIBUTE -DQT_COMPILER_SUPPORTS_AESNI -IC:\qt-everywhere-src-5.11.1\qtbase\config.tests\x86_simd -I. -IC:\openssl-1.0.2o\out32dll -IC:\qt-everywhere-src-5.11.1\qtbase\mkspecs\win32-msvc -Fo @C:\Users\msrei\AppData\Local\Temp\main.obj.16356.0.jom
> main.cpp
>   link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:x86_simd.exe @C:\Users\msrei\AppData\Local\Temp\x86_simd.exe.16356.93.jom
test config.qtbase.tests.aesni succeeded
loaded result for config test config.qtbase.tests.alloca_h
+ cd /d C:\qt_build\config.tests\alloca_h && C:\qt_build\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl-1.0.2o\\out32dll" "INCLUDEPATH += C:\\openssl-1.0.2o\\out32dll" C:/Entwicklung/qt_build/config.tests/alloca_h
+ cd /d C:\qt_build\config.tests\alloca_h && set MAKEFLAGS=& jom clean && set MAKEFLAGS=& jom
> jom 1.1.2 - empower your cores
>   del main.obj
> C:\qt_build\config.tests\alloca_h\main.obj konnte nicht gefunden werden
>   del alloca_h.exp alloca_h.vc.pdb alloca_h.ilk alloca_h.idb
> C:\qt_build\config.tests\alloca_h\alloca_h.exp konnte nicht gefunden werden
> jom 1.1.2 - empower your cores
>   cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -W0 -EHsc /Fdalloca_h.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl-1.0.2o\out32dll -IC:\qt-everywhere-src-5.11.1\qtbase\mkspecs\win32-msvc -Fo @C:\Users\msrei\AppData\Local\Temp\main.obj.14548.0.jom
> main.cpp
> main.cpp(2): fatal error C1083: Datei (Include) kann nicht ge"ffnet werden: "alloca.h": No such file or directory
> jom: C:\qt_build\config.tests\alloca_h\Makefile [main.obj] Error 2
test config.qtbase.tests.alloca_h FAILED

It worked using openssl 1.0.2 configured like this:

CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86
perl Configure VC-WIN32 --prefix=C:/openssl
nmake -f ms/ntdll.mak
nmake -f ms/ntdll.mak install

and this configure:

D:/qt-everywhere-src-5.10.0/configure -platform win32-msvc2017 -prefix win32-msvc2017 -opensource -confirm-license -debug-and-release -force-debug-info -nomake examples -nomake tests -skip qtwebengine -skip qt3d -ssl -openssl-linked OPENSSL_PREFIX=C:\openssl

for using it in a Qt-Project with MSVC2017 add this to your projects .pro file

win32-msvc* {
    LIBS += -LC:/openssl/lib/ -llibeay32
    LIBS += -LC:/openssl/lib/ -lssleay32
    INCLUDEPATH += C:/openssl/include
}

Building Qt Desktop for Windows with MSVC, C: (for OpenSSL library or unpack source code anywhere for build) … It is not required to install examples, demos, docs,  This article shows how to build OpenCV (or any external library using cmake) on Windows with the MSVC2017 compiler and using the QtCreator to build applications using the OpenCV library. This can be necessary if you want to use qtwebengine currently not supported by MinGW compiler. This article assumes a standard installation of Windows 10 and Qt.


I don't know about Qt 5.10, but for 5.11.1, the following works - open a CMD prompt and run vcvarsall first, of course.

build-openssl.bat
@set SRC=openssl-1.0.2o
@if "%VSCMD_ARG_TGT_ARCH%"=="x86" (
    @set BITS=32
    @set DST=OpenSSL-Win32
    @set CONFIG=VC-WIN32
    @set SETUP=ms\do_nasm
) else if "%VSCMD_ARG_TGT_ARCH%"=="x64" (
    @set BITS=64
    @set DST=OpenSSL-Win64
    @set CONFIG=VC-WIN64A
    @set SETUP=ms\do_win64a
) else goto no_vscmd
@echo Building %SRC% for %BITS% bits.

@echo - Downloading
@perl ^
    -e "use LWP::Simple;" ^
    -e "mirror('https://www.openssl.org/source/%SRC%.tar.gz', '%SRC%.tar.gz');"

@echo - Decompressing
@if not exist %SRC%.tar.gz goto no_archive
@rmdir /S /Q %SRC% %DST% 2>NUL
@7z x -bsp2 -y %SRC%.tar.gz >NUL && ^
7z x -bsp2 -y %SRC%.tar     >NUL && ^
del %SRC%.tar
@if errorlevel 1 goto unpack_failed
@if not exist %SRC% goto no_source

@echo - Building
@pushd %SRC%
@perl Configure %CONFIG% --prefix=%~dp0..\%DST% && ^
call %SETUP% && ^
nmake -f ms\nt.mak init && ^
jom -f ms\nt.mak "CC=cl /FS" && ^
jom -f ms\nt.mak test && ^
nmake -f ms\nt.mak install || goto build_failed
@popd
@rmdir /S /Q %SRC%

@echo Build has succeeded.
@goto :eof

:no_archive
@echo Error: can't find %SRC%.tar.gz - the download has failed :(
@exit /b 1

:unpack_failed
@echo Error: unpacking has failed.
@exit /b %errorlevel%

:no_source
@echo Error: can't find %SRC%\
@exit /b 1

:build_failed
@echo The build had failed.
@popd
@exit /b 2

:no_vscmd
@echo Use vcvars-32 or vcvars-64 to set up the Visual Studio
@echo build environment first.
@exit /b 100

Then, to build Qt 5.11.1, I use the following configuration:

-opensource
-confirm-license
-force-debug-info
-debug-and-release
-ltcg
-openssl
-qt-zlib
-qt-libpng
-qt-libjpeg
-plugin-sql-sqlite
-mp
OPENSSL_PREFIX="c:\foo\OpenSSL-Win32"
-nomake examples
-make-tool jom
-platform win32-msvc
-opengl dynamic
-no-iconv
-no-dbus

Where foo is whatever folder you happened to run build-openssl.bat in.

Ensure that you have jom in the path, otherwise you'll hate the whole process. The latest jom is at: http://download.qt.io/official_releases/jom/jom.zip

The script to add all the tools into your path (so that you don't have to set it globally):

toolpaths.bat
@set V_7ZIP=%ProgramFiles%\7-Zip
@set V_PERL64=C:\Perl64
@set V_PERL32=C:\Perl
@set V_PYTHON27=C:\Python27
@set V_NASM=%ProgramFiles%\NASM
@set V_NASM32=%ProgramFiles(x86)%\NASM
@set V_SMARTGIT32=%ProgramFiles(x86)%\SmartGit
@set V_SMARTGIT=%ProgramFiles%\SmartGit
@set V_CMAKE=%ProgramFiles%\CMake
@set V_CMAKE32=%ProgramFiles(x86)%\CMake
@set V_VS2015=2015
@set V_VS2015COMNTOOLS=%VS140COMNTOOLS%
@set V_VS2017COMNTOOLS=%VS150COMNTOOLS%

@if not exist "%V_7ZIP%\7z.exe" goto no_7zip
@call :append_path "%V_7ZIP%"
@goto has_7zip
:no_7zip
@echo Warning: 7-Zip not installed. OpenSSL will not build.
:has_7zip

@if not exist "%V_PERL64%\bin" goto no_perl64
@if not exist "%V_PERL64%\site\bin" goto no_perl_site64
@call :append_path "%V_PERL64%\site\bin"
:no_perl_site64
@call :append_path "%V_PERL64%\bin"
@goto has_perl
:no_perl64

@if not exist "%V_PERL32%\bin" goto no_perl
@if not exist "%V_PERL32%\site\bin" goto no_perl_site32
@call :append_path "%V_PERL32%\site\bin"
:no_perl_site32
@call :append_path "%V_PERL32%\bin"
@goto has_perl
:no_perl
@echo Warning: Perl not installed. Qt will not build.
:has_perl

@if not exist "%V_PYTHON27%" goto no_python
@call :append_path "%V_PYTHON27%"
@goto has_python
:no_python
@echo Warning: Python 2.7 not installed. Qt will not build.
:has_python

:check_nasm
@if not exist "%V_NASM%\nasm.exe" goto check_nasm32
@call :append_path "%V_NASM%"
@goto has_nasm
:check_nasm32
@if not exist "%V_NASM32%\nasm.exe" goto no_nasm
@call :append_path "%V_NASM32%"
@goto has_nasm
:no_nasm
@echo Warning: NASM not installed. OpenSSL will not build.
:has_nasm

:check_git
@if not exist "%V_SMARTGIT%\git\bin" goto check_git32
@call :append_path "%V_SMARTGIT%\git\bin"
@goto has_git
:check_git32
@if not exist "%V_SMARTGIT32%\git\bin" goto no_git
@call :append_path "%V_SMARTGIT32%\git\bin"
@goto has_git
:no_git
@echo Warning: SmartGit not installed. Qt WebEngine might not build.
:has_git

:check_cmake
@if not exist "%V_CMAKE%\bin\cmake.exe" goto check_cmake32
@call :append_path "%V_CMAKE%\bin"
@goto has_cmake
:check_cmake32
@if not exist "%V_CMAKE32%\bin\cmake.exe" goto no_cmake
@call :append_path "%V_CMAKE32%\bin"
@goto has_cmake
:no_cmake
@echo Info: CMake not installed. This is without consequences.
:has_cmake

:: configure gyp overrides for msvs 2017 express
@if not exist "%VS150COMNTOOLS%\VsDevCmd.bat" goto no_vs2017gyp
@call :set_path V_VS2017 "%VS150COMNTOOLS%\..\.."
@echo Info: Found MSVS 2017 at "%V_VS2017%"
@set GYP_MSVS_VERSION=2017
@set GYP_MSVS_OVERRIDE_PATH=%V_VS2017%
@goto no_vs2015gyp
:no_vs2017gyp

:: configure gyp overrides for msvs 2015 express
@if not exist "%VS140COMNTOOLS%\..\IDE\WDExpress.exe" goto no_vs2015gyp
@call :set_path V_VS2015 "%VS140COMNTOOLS%\..\.."
@echo Info: Found MSVS Express 2015 at "%V_VS2015%"
@set GYP_MSVS_VERSION=2015
@set GYP_MSVS_OVERRIDE_PATH=%V_VS2015%
:no_vs2015gyp

@exit /b

:append_path
@echo %PATH%|find "%~1">nul || PATH %PATH%;%~1
@goto :eof

:set_path
@set %1=%~f2
@goto :eof

Building Qt5 with OpenSSL support using VS 2015, I'm looking for some guidance on building Qt5 with OpenSSL support using VS Hi, I just build Qt from source with the instructions found here: -prefix C:\Qt\​Static\5.12.0 -platform win32-msvc2017 -qt-zlib -qt-pcre -qt-libpng  As you see, I do not want to build Qt3 support module, some styles, using image libs from Qt source, some additional instructions sets are enabled and some another stuff. Ok, let’s configure… Accepting license… Please, wait… (building qmake now) :) All the project’s files are read and now we able to build libs, tools, examples, etc.


Building Qt 5.12.3 on Windows 10 with Visual Studio 2017, As mentioned before, building Qt from source by yourself may not be neccessary when you run up-to-date versions -platform win32-msvc2017, Use Microsoft Visual C++ 2017. -no-openssl, Do not use OpenSSL support. I realise I'm by no means the first person to ask for help on this but hopefully someone might spot something I'm doing wrong with my approach in attempting a static build of Qt 5.9.2 from source (github or zip download) with a Visual Studio 2017 x86 nati


Building Qt 5.9.1 on Windows 7/10 with Visual Studio 2017, Time again for a follow-up to my post on building Qt's recent LTS release where you can get the source code of 5.9.1 for Windows as a zip file. -platform win32-msvc2017, Use Microsoft Visual C++ 2017. -no-openssl  You can also select where qBittorrent will be built if you want. If you are compiling qBittorrent v3_3_x branch, open the winconf.pri file and adjust the paths. If v4_0_x branch is used, open conf.pri.windows, save it as conf.pri and adjust the paths. Disregard most of the file comments (read next step).


How to build static version of Qt with ICU and OpenSSL linked, cd /C/ICU/src/source ./runConfigureICU MSYS/MSVC --enable-static --disable-​shared --prefix=$PWD/../../icu4c-x86-static-msvc2017 make -j4 && make install. Dear @SGaist I used Qt 5.13.1 (MSVC 2017 64-bit) console. It can't find 64-bit MSVC compiler on my machine so I have to add it in path environment variable. And know it just can't find header files and I have to add all include folders in include environment variable.


wangwenx190/build-scripts: Build scripts for some open , Build scripts for some open source projects, just for personal use. - wangwenx190/build-scripts. Eg: %comspec% /k "C:\Qt\Qt5.12.0\5.12.0\​msvc2017\win-setup-qt-env.bat" x64 . build-static-version-of-qt-with-icu-and-​openssl-linked.md. Qt for UWP - Building from Source Additional Information The top-level qt5 Git repository contains a set of build instructions in the form of provisioning scripts , used by Qt's continuous integration (CI) system to build and test the supported Reference Configurations .