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
580 views
in Technique[技术] by (71.8m points)

c++ - QSslSocket: cannot call unresolved function

I am running Qt 5.7.1 (MSVC 2015, 32 bit) with Qt Creator 4.2.0. I have a problem with QSslSocket. I am getting the following errors:

qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error

I have gone to the following location openssl github and downloaded the zip file. I have moved the "libeay32.dll" and "ssleay32.dll" files to my release directory, and I am still getting these errors. Is there anyone who has gotten the QSslSocket working that can give me steps to get the socket working or has any suggestions?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

I ended up here via Googling around. In my case, I was getting this error on random machines because they were missing the correct versions of libeay32.dll and ssleay32.dll. It's "random" because some computers have these loaded in PATH from other software and some do not.

I fixed this for Qt Creator by adding the DLLs to the bin folder of my Qt install, and I fixed this on distributions by including the aforementioned DLLs in my distribution.

The DLLs should be the same or similar to the version of OpenSSL that Qt was compiled with in the first place. If you didn't compile it yourself, starting in Qt 5.4 you can query this with QSslSocket::sslLibraryBuildVersionString(). (Credit: https://stackoverflow.com/a/42297296/1666676)

Don't forget that your 64-bit apps should have a 64-bit version of the DLLs, and 32-bit apps should have 32-bit DLLs so you don't have the same problem as this guy.


Additional notes:

  • Starting in Qt 5.2 you must use version 1.0.0 or newer. 0.9.8 doesn't work any more. (Source: http://doc.qt.io/qt-5/ssl.html)
  • For my standard MSVC2017x64 distribution of Qt 5.10.1 sslLibraryBuildVersionString() returned "OpenSSL 1.0.2o". I use 1.0.2p for my distributions.
  • The OpenSSL DLLs changed names to libcrypto-1_1*.dll and libssl-1_1*.dll starting in OpenSSL 1.1.0. Standard Qt distributions don't yet use those as of Sept. 2018.
  • OpenSSL GitHub downloads are here: https://github.com/openssl/openssl/tags

Hope this helps the next person. Sorry for resurrecting an old post.


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

...