{"id":354,"date":"2020-08-30T23:47:12","date_gmt":"2020-08-30T21:47:12","guid":{"rendered":"http:\/\/xpam.pl\/blog\/?p=354"},"modified":"2024-04-03T01:35:58","modified_gmt":"2024-04-02T23:35:58","slug":"building-qt-5-15-on-windows-with-openssl","status":"publish","type":"post","link":"https:\/\/xpam.pl\/blog\/?p=354","title":{"rendered":"Building Qt 5.15 on Windows with OpenSSL"},"content":{"rendered":"<p>I have written about the many problems of <a href=\"http:\/\/xpam.pl\/blog\/?p=106\">building Qt 5 with OpenSSL in the past<\/a>. Several years later, it is time to upgrade to latest Qt 5.15 which is presumably the last in the Qt 5 series. This time I decided to drop the Windows XP support since it is just too much work to get working and XP market share is much lower today than it was 5 years ago.<\/p>\n<p>Since the Qt build documentation is still lacking here is the latest text of the ordeal.<\/p>\n<p>First thing first, install <a href=\"http:\/\/strawberryperl.com\/\">Strawberry Perl<\/a> and Python 2 (yeah.. really).<\/p>\n<p>For speedier builds, also install <a href=\"https:\/\/wiki.qt.io\/Jom\">jom<\/a>. We will also need <a href=\"https:\/\/github.com\/microsoft\/vcpkg\">vcpkg<\/a> to get the OpenSSL binaries. Needless to say, all these tools need to be in your system PATH.<\/p>\n<p>Now get the code:<\/p>\n<pre><code class=\"language-bash\">\ngit clone git:\/\/code.qt.io\/qt\/qt5.git\ncd qt5\ngit checkout v5.15\nperl init-repository<\/code><\/pre>\n<p>I think you can tell the init-repository script to not download some of the modules you don't need (it pulls 12GB of data!) but I couldn't be bothered to find the flags for that. You can probably avoid it by downloading the source archive instead of doing it via git.<\/p>\n<p>Today we finally have the C\/C++ package managers available to not bother bulding the dependencies anymore. Vcpkg and conan are both great tools that do the job. So forget about building OpenSSL, just install the binaries with vcpkg:<br \/>\n<code>.\/vcpkg.exe install openssl<\/code><br \/>\nIn your user env, add<br \/>\n<code>OPENSSL_LIBS=-llibssl -llibcrypto<\/code><br \/>\nNow we can run the configure script inside the qt5 folder. First we do a release build and we link to openssl (run in Visual Studio cmd):<br \/>\n<code>.\\configure.bat -v -release -opensource -nomake examples -opengl desktop -platform win32-msvc2015 -openssl -openssl-linked -I C:\/Users\/me\/git\/vcpkg\/installed\/x86-windows\/include -L C:\/Users\/me\/git\/vcpkg\/installed\/x86-windows\/lib<\/code><br \/>\nChange the location of OpenSSL include and lib folders to whatever your vcpkg installation directory is. I am still targeting msvc2015 for now but I plan to transition to 2019 eventually.<\/p>\n<p>If you change around the configure parameters, make sure to delete <strong>config.cache<\/strong> file since in my experience it likes to save unwanted information from previous runs.<\/p>\n<p>Build it with jom:<\/p>\n<pre><code class=\"language-bash\">jom\njom install<\/code><\/pre>\n<p>Now you have a release build and you can add it in Qt Creator under <code>Tools -&gt; Options -&gt; Qt Versions<\/code> by giving it the path to <code>C:\\Qt\\Qt-5.15.1\\bin\\qmake.exe<\/code>.<\/p>\n<p>If you also need debug build of Qt, you can repeat the configure and build step by replacing <code>-release<\/code> flag with <code>-debug<\/code> (remember to delete config.cache first).<\/p>\n<p>An there you have it.. Qt built from source with OpenSSL support. Once you build your program you will also have to copy all the relavant .dll files into the .exe build directory (Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll&#8230;). The amount of libraries you need to copy depends on what you are actually using in your code. You will also need to copy <code>libcrypto-1_1.dll<\/code> and <code>libssl-1_1.dll<\/code> from the vcpkg install directory.<\/p>\n<p>For debug builds you need to copy the debug libraries (Qt5Core<strong>d<\/strong>.dll) instead.<\/p>\n<p>The future appears to be even brighter now that <a href=\"https:\/\/github.com\/bincrafters\/conan-qt\">bincrafters have packaged Qt as a conan recipe<\/a>.\u00a0Which means the next time I need to depend on Qt, I will run a single conan command and get the proper build automagically delivered to my PC along with all the transitive dependencies. The future is now.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"wp-post-signature\">\r\n<br \/>\r\n<br \/>\r\n<img src='https:\/\/xpam.pl\/aaaaff.png' title='Moonie' \/> Cen<br \/>\r\n<a href='https:\/\/github.com\/cen1'>GitHub<\/a><br \/>\r\n<a href='https:\/\/eurobattle.net'>Eurobattle.net<\/a><br \/>\r\n<a href='https:\/\/lagabuse.com'>Lagabuse.com<\/a><br \/>\r\n<a href='https:\/\/bnetdocs.org'>Bnetdocs<\/a><br \/>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>I have written about the many problems of building Qt 5 with OpenSSL in the past. Several years later, it is time to upgrade to latest Qt 5.15 which is presumably the last in the Qt 5 series. This time I decided to drop the Windows XP support since it is just too much work [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,3],"tags":[],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-c","category-programming"],"_links":{"self":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354"}],"version-history":[{"count":9,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":559,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/354\/revisions\/559"}],"wp:attachment":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}