Enabling OpenSSL for Qt C++ on Windows

By default, Nokia Qt does not ship its Qt C++ framework with OpenSSL enabled. This degrades value of the framework and you won’t be able to access HTTPS pages or SSL enabled web services. The examples that require SSL won’t work as well. Take examples\webkit\googlechat for example. This post gives an approach to enable OpenSSL for Qt C++ framework on Windows.

Make sure you have readandbefore proceeding.

  1. Open CMD console & go to the directory C:\Qt\2010.02.1\qt\src\network (given that you have Qt 4.6.2. installed using standard options offered by the installer)
  2. Make sure the directories C:\Qt\2010.02.1\qt\bin and C:\Qt\2010.02.1\mingw\bin are in the environment variable PATH. If you are unsure, enter this command:

set PATH=%PATH%;C:\Qt\2010.02.1\mingw\bin;C:\Qt\2010.02.1\qt\bin;

  1. Configure QtNetwork build using this one-liner:

qmake "PWD=C:\Qt\2010.02.1\qt\src\network" "QMAKE_LIBS_NETWORK = -lws2_32 -lcrypto -leay32 -lssl32 -lssl -lgdi32" "DEFINES += QT_LINKED_OPENSSL" "DEFINES -= QT_NO_SSL"

It’s your responsibility to ensure that OpenSSL is installed and visible to MinGW.

  1. Go ahead with building with this single command:

mingw32-make

Wait for 5-10 mins and you have QtNetwork with OpenSSL enabled. Enjoy!

7 thoughts on “Enabling OpenSSL for Qt C++ on Windows”

  1. Thank you for this! It took me two tries because when I ran it the first time I had to deal with your website’s formatting screwing up some things initially….that and the fact that I hadn’t properly copied all of the files.

  2. Thanks for this useful tutorial. everything sets fine but not the last one ie “mingw32-make” command, that gave me error like:
    C:\Qt\4.7.3\src\network>mingw32-make
    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Qt/4.7.3/src/network’
    Makefile.Debug:222: *** missing separator. Stop.
    mingw32-make[1]: Leaving directory `C:/Qt/4.7.3/src/network’
    mingw32-make: *** [debug] Error 2

    Please can you give me a hint where I have missed something. Thanks in advance.

  3. @Loony Salmon: Glad it help. You are welcome.

    @Rax: Could you please post your Makefile.Debug file to pastebin or similar sites so that I could take a look?

  4. Hello Le,
    Thanks for reply. Well you can find the my makefile.debug file from https://sites.google.com/site/blackberrydigger/Makefile.Debug?attredirects=0&d=1

    After running the step (3) i got:
    C:\Qt\4.7.3\src\network>qmake “PWD=C:\Qt\4.7.3\src\network” “QMAKE_LIBS_NETWORK=-lws2_32 -lcrypto -leay32 -lssl32 -lssl -lgdi32” “DEFINES += QT_LINKED_OPENSSL” “DEFINES -= QT_NO_SSL”
    WARNING: (internal):1: Unescaped backslashes are deprecated.
    WARNING: c:\Qt\4.7.3\src\network\ssl\ssl.pri:8: Unable to find file for inclusio
    n \config.tests\unix\openssl\openssl.pri
    WARNING: (internal):1: Unescaped backslashes are deprecated.
    WARNING: c:\Qt\4.7.3\src\network\ssl\ssl.pri:8: Unable to find file for inclusio
    n \config.tests\unix\openssl\openssl.pri
    WARNING: (internal):1: Unescaped backslashes are deprecated.
    WARNING: c:\Qt\4.7.3\src\network\ssl\ssl.pri:8: Unable to find file for inclusio
    n \config.tests\unix\openssl\openssl.pri

    then,

    c:/qt/4.7.3/src/network>mingw32-make
    i got following output on prompt : http://pastebin.com/K15cs3Ez

    —-FYI—
    QTDIR=c:\qt\4.7.3
    QMAKESPEC=win32-g++
    env path : http://pastebin.com/LewVgDRE
    openssl install path= C:\openssl-0.9.8n
    Active Perl = C:\Perl
    mingW = C:\Qt\4.7.3\mingw

  5. Hi, I’m trying to follow your tutorial for qt 4.7.4.
    I’m not so expert, so what I have to do exactly at point 3?
    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *