I am trying to make a static build of Qt (version 5.4.1) with OpenSSL support. I configured it as follows:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl-linked -I C:\OpenSSL-Win32\include
-L C:\OpenSSL-Win32\lib\VC\static
-nomake examples -nomake tests
The include and lib directories are valid. I am getting loads of linking errors in Qt5Network.lib
.
Qt5Network.lib(qhttpnetworkconnectionchannel.obj) : error LNK2019: unresolved ex
ternal symbol "public: static class QSharedPointer<class QSslContext> __cdecl QS
slSocketPrivate::sslContext(class QSslSocket *)" (?sslContext@QSslSocketPrivate@
@SA?AV?$QSharedPointer@VQSslContext@@@@PAVQSslSocket@@@Z) referenced in function
"protected: void __thiscall QHttpNetworkConnectionChannel::_q_connected(void)"
(?_q_connected@QHttpNetworkConnectionChannel@@IAEXXZ)
Qt5Network.lib(qhttpprotocolhandler.obj) : error LNK2019: unresolved external sy
mbol "public: __int64 __thiscall QSslSocket::encryptedBytesToWrite(void)const "
(?encryptedBytesToWrite@QSslSocket@@QBE_JXZ) referenced in function "private: vi
rtual bool __thiscall QHttpProtocolHandler::sendRequest(void)" (?sendRequest@QHt
tpProtocolHandler@@EAE_NXZ)
C:\Qt\5.4\qtbase\bin\xmlpatterns.exe : fatal error LNK1120: 31 unresolved extern
als
jom: C:\Qt\5.4\qtxmlpatterns\tools\xmlpatterns\Makefile [release] Error 2
jom: C:\Qt\5.4\qtxmlpatterns\tools\Makefile [sub-xmlpatterns-make_first] Error 2
jom: C:\Qt\5.4\qtxmlpatterns\Makefile [sub-tools-make_first] Error 2
jom: C:\Qt\5.4\Makefile [module-qtxmlpatterns-make_first] Error 2
I was able to create a static build before without OpenSSL support. The error messages also suggest, that the problem is associated to OpenSSL.
Does anyone has an idea to resolve this?
UPDATE
These configurations are producing the same error:
Configuration 1:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl-linked -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib\VC\static
OPENSSL_LIBS="-llibeay32MT -lssleay32MT" -nomake examples -nomake tests
Configuration 2:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32
-nomake examples -nomake tests
UPDATE 2
I also tried so follow the great tutorial in the qBittorrent wiki, and got the same errors.
If this is indeed a Qt bug, as Frank suggested in his comment, it would be also really useful if someone could suggest the last version of Qt, with which this should work.
UPDATE 3
On bugreports.qt.io I have received the opinion, that this is not a bug:
You haven't actually told the build to link the openssl libraries. http://doc.qt.io/qt-5/ssl.html gives the following example:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
You'll need to tweak it for your compiler and library locations of course.
On the referred documentation page this example is given:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
I do not find the ssl or the crypto libraries in the OpenSSL build I compiled, nor in the binary distribution. I do have the headers though. I only have the ssleay32 and libeay32 libraries.
The configure command does hint to set these libraries to the mentioned variable:
NOTE: When linking against OpenSSL, you can override the default
library names through OPENSSL_LIBS
and optionally OPENSSL_LIBS_DEBUG/OPENSSL_LIBS_RELEASE
For example:
configure -openssl-linked OPENSSL_LIBS="-lssleay32 -llibeay32"
By setting this variable I still get the same errors.
UPDATE 5
Not exactly what I wanted, but a step forward:
I have downloaded the sources for the recently (4 days ago) released Qt 5.4.2, and with that I was able to create a static build with a dynamicly linked OpenSSL (-openssl switch).
I am still looking for a solution to staticly link OpenSSL. I still have the same linking errors.