Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Static build of Qt, Qt5Network linking error
agabor last edited by agabor
I am having some problem compiling qt staticaly with OpenSSL support. I have asked this question on StackOveflow without much success. Please exuse me for copy-pasting the question as is:
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(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?
These configurations are producing the same error:
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
configure -opensource -release -c++11 -static -platform win32-msvc2013 -openssl -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32 -nomake examples -nomake tests
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.
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
You'll need to tweak it for your compiler and library locations of
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.
Could someone help me out with this, please?