Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

c++ - QT https SSL support for static QT static program build - getting 'Protocol "https" is unknown'

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:SystemRootSystem32cmd.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-Win32include"

    LIBS += -LC:OpenSSL-Win32lib -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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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-Win32include
-L C:OpenSSL-Win32libVCstatic
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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...