3

Hi I am trying to compile a QT program I made for Windows statically and keep getting the error Protocol "https" is unknown when running an update database function that uses https in the address that the update function uses. It works when run through QT Creator as I have openssl installed however apparently the static executable doesn't have the proper libraries to do https. I did find this and this. I looked all over the net trying to find a solution but couldn't. Here's what I've done so far:

  1. edited the powershell script here to include the parameter -openssl-linked for configure.bat instead of -no-openssl

    $env:SystemRoot\System32\cmd.exe /c "configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir
    -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -openssl-linked
    -opensource -confirm-license
    -make libs -nomake tools -nomake examples -nomake tests"
    
  2. verified config.summary to contain the following:

    SSL support.................linked

    OpenSSL support.............linked

  3. Put openssl libraries libeay32.dll and libssl32.dll and ssleay32.dll in my build release directory with the executable compiled in the directory

  4. put the following the qt project file:

    INCLUDEPATH += "C:\OpenSSL-Win32\include"

    LIBS += -LC:\OpenSSL-Win32\lib -llibeay32 -lssleay32

One thing I didn't do however was a clean between the original QT static build using the powershell script and the subsequent build with the -openssl-linked option. Don't know if that would be necessary. Any ideas? Thanks!

Community
  • 1
  • 1
riverofwind
  • 525
  • 4
  • 17

2 Answers2

2

In spite of what configure indicates, you have not provided enough information to configure to let it link Qt with OpenSSL.

You need to link Qt with OpenSSL at the time it is being built. Pass the following arguments to configure (this is for Qt 5):

-openssl-linked
-I C:\OpenSSL-Win32\include
-L C:\OpenSSL-Win32\lib\VC\static
OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32"
OPENSSL_LIBS_DEBUG=-"lssleay32MTd -llibeay32MTd"
OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT"

There's no need for any special parameters to be passed while building your project.

The above assumes a build from Shining Light Productions, the de-facto OpenSSL binary purveyor for Windows.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Thanks so much! I will try tomorrow. Should I do C:\OpenSSL-Win32\include\openssl for the -I option? There is nothing in the include directory other than the openssl dir. Also I am using Mingw so should I do C:\OpenSSL-Win32\lib\MinGW or C:\OpenSSL-Win32\lib for -L? Or should I do C:\OpenSSL-Win32\lib\VC\static.... – riverofwind Feb 17 '16 at 05:35
  • @JoshOrenberg It should definitely be MinGW, yes. – Kuba hasn't forgotten Monica Feb 17 '16 at 06:22
  • How about for -I? The full path or just as in the first reply? I wanna make sure I get it right since it takes like half a day to compile lol – riverofwind Feb 17 '16 at 06:43
  • @JoshOrenberg There is no compiler specific include path for OpenSSL. You don't have to ask me, in fact, just look in what you downloaded. All the paths you give to `configure` must exist. – Kuba hasn't forgotten Monica Feb 17 '16 at 10:15
  • I think you misunderstood my question - C:\C:\OpenSSL-Win32\include is empty except the subdir openssl which has all the headers in it. I have two more quick questions - the MinGW dir has only two .a and two .def files while the lib dir has all the libs in it. So to use the dir MinGW or not to use and to go with the libs dir for -L. The other question is do I need to do a clean before reconfiguring with these settings. I have tried mingw32-make confclean but I get "mingw32-make: *** No rule to make target 'confclean'. Stop." – riverofwind Feb 18 '16 at 20:29
  • @JoshOrenberg Forget about `distclean`. You're supposed to do out-of-source builds. Delete the entire build folder to start clean. *C:\OpenSSL-Win32\include is empty except [...]* So, not empty, then :) *the lib dir has all the libs in it* `.a` is gnu-speak for `.lib`. How many libraries do you expect to have for OpenSSL? Two is plenty. These are the ones Qt will statically link with. Go for it. You're overthinking it all, I think. – Kuba hasn't forgotten Monica Feb 19 '16 at 14:04
  • I'm about to give up... I got it to work but only with the libeay32.dll and ssleay32.dll present. I thought I did it statically. I passed the following to configure, also IIRC I tried -L C:\OpenSSL-Win32\lib\MinGW but then I had to add the libs to the .pro file... -I C:\OpenSSL-Win32\include ` -L C:\OpenSSL-Win32\lib ` OPENSSL_LIBS=""-lUser32 -lAdvapi32 -lGdi32 -lCrypt32"" ` OPENSSL_LIBS_DEBUG=-""-lssleay32 -llibeay32"" ` OPENSSL_LIBS_RELEASE=""-lssleay32 -llibeay32"" ` – riverofwind Feb 22 '16 at 00:56
  • scratch that IIRC, I actually wrote it down so it definitely was tried – riverofwind Feb 22 '16 at 01:13
0

I contacted Shining Light Productions, they say no static libraries for mingw. Also I passed -openssl-linked -I C:/OpenSSL-Win32/include -L C:/OpenSSL-Win32/lib to configure by editing QT's powershell script for static building with success (you just need the openssl dlls present with the .exe for it to work...).

GMchris
  • 5,439
  • 4
  • 22
  • 40
riverofwind
  • 525
  • 4
  • 17