-
Notifications
You must be signed in to change notification settings - Fork 364
Compile Qt 64 bit with OpenSSL using VisualStudio 2015 and MT
Additionally to visual studio, Perl and Nasm are required. They should be installed and in the PATH so they can be called from the command line. Next, open the visual studio command line for x64 (VS2015 x64 Native Tools Command Prompt). First, we configure opensSSL for windows 64. With the --prefix option you can optionally set a different directory where you want to install openssl (the default on windows is C:\Program Files\openSSL)
# For openssl 1.0.x
perl Configure VC-WIN64A --prefix=..\openssl-release
ms\do_win64a.bat
# For openssl 1.1.x
perl Configure VC-WIN64A
Now we can compile openSSL in two configurations:
- As a dynamically linked exe with two dlls. All compiled with /MD
- As a statically linked exe with no dlls. All compiled with /MT
What we want, however, is a dynamically linked exe with two dlls compiled with /MT. For this, we edit the makefile and replace the /MD C Flag by /MT (On 1.0.x: ms\ntdll.mak; On 1.1.x: makefile). Then we compile openSSL:
# For openssl 1.0.x
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak install
# For openssl 1.1.x
nmake
nmake install
The install command will copy all the includes and libraries into the given prefix folder (..\openssl-release). If you did not select a prefix folder you might need administrative privileges to install openSSL (remeber the default is C:\Program Files\openSSL).
Before building Qt, consider the paths that you use. The source can be placed anywhere while the version of Qt that you compile will be bound to the specific directory that you compiled it in. Some components within Qt use absolute paths (yes I know) which makes moving Qt to a different directory harder (maybe there is a way though which I don't know about).
Get the sources of Qt from https://www.qt.io/download/ or check them out using git. If you use the installer, we really only need the sources of Qt (and possibly Qt Charts and Qt Data Visualization). If working with mingw, you will have to add the gnuwin32\bin folder to the PATH:
SET PATH=C:\projects\Qt\5.8\Src\gnuwin32\bin;%PATH%
Next, we also want QT to be built statically linked against the windows runtime. Go to the qt source foleder qtbase\mkspecs\common and change msvc-desktop.conf. Replace the -MD switch by -MT and the -MDd switch by -MTd.
Then, create a new folder (maybe named "Qt5.x-build") and cd to it. We will create a shadow build in this folder in release mode. If you also want the debug versions, just create another debug folder and configure Qt in debug mode. Next, configure Qt to build in this new folder. This line is so long because we skip a lot of the packages that we don't use in YUView. This will speed up compilation significantly. Just re-activate whatever you also might need. The path for openSSL (include and lib folder) are also here in this line which you have to apat to your local filesystem.
C:\projects\Qt\5.8\Src\configure.bat -release -opensource -confirm-license -opengl dynamic -platform win32-msvc2015 -openssl -IC:\projects\openSSL\openSSL-release\include -LC:\projects\openSSL\openSSL-release\lib -nomake examples -nomake tests -no-direct2d -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtconnectivity -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquickcontrols2 -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qttranslations -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns
There are some optional but very helpful options which might help:
- prefix: Change the folder in which Qt will be installed when calling
nmake isntall
. This is important if you plan to use the windeployqt tool as it will look in this directory for the qt libraries. The default dir is C:\Qt\Qt-5.xx\
Start the build of Qt with nmake
or jom
. Jom can be downloaded from the Qt page and allows for multiprocessor compilation. You can install the libraries into a folder by using nmake install
.