Unable to build Qt 5.7 using MSVC 2015 - unresolved OpenSSL symbols
-
I have spent the past few hours attempting to compile the source code for the latest Qt version so I can submit code to be reviewed. I am unable to build the source code to test the binaries.
I am attempting to build Qt 5.7 using MSVC 2015 on Windows 10. I have installed 32-bit precompiled binaries for OpenSSL v1.0.1u from https://slproweb.com/products/Win32OpenSSL.html. The default install location is C:/OpenSSL-Win32. I copied the include folder and relevant libraries to MSVC's folder. (I copied the libs from inside the VC subdirectory to MSVC lib folder as well).
Next, I simply setup a command prompt with the appropriate environment variables and path. This is my qt5vars.cmd used:
REM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc. CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 SET _ROOT=C:\Qt-source\qt5 SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH% REM Uncomment the below line when using a git checkout of the source repository SET PATH=%_ROOT%\qtrepotools\bin;%PATH% SET PATH=C:\OpenSSL-Win32\bin;%PATH% SET QMAKESPEC=win32-msvc2015 SET _ROOT=
Next, I open a command prompt with the qt5vars.cmd, go to the source directory and configure the source.
configure -platform win32-msvc2015 -developer-build -opensource -nomake tests -nomake examples
Finally, I call nmake to build the files. Unresolved external symbol errors come up for six OpenSSL commands in the qtnetwork folder. Here are the errors:
link /NOLOGO /DYNAMICBASE /NXCOMPAT /BASE:0x64000000 /DEBUG /DLL /SUBSYSTEM:WINDOWS /VERSION:5.7 /MANIFEST:embed /OUT:..\..\lib\Qt5Networkd.dll @C:\Users\addis\AppData\Local\Temp\nm4FF.tmp Creating library ..\..\lib\Qt5Networkd.lib and object ..\..\lib\Qt5Networkd.exp qsslcontext_openssl.obj : error LNK2019: unresolved external symbol "struct ssl_method_st const * __cdecl q_SSLv3_client_method(void)" (?q_SSLv3_client_method@@YAPBUssl_method_st@@XZ) referenced in function "private: static void __cdecl QSslContext::initSslContext(class QSslContext *,enum QSslSocket::SslMode,class QSslConfiguration const &,bool)" (?initSslContext@QSslContext@@CAXPAV1@W4SslMode@QSslSocket@@ABVQSslConfiguration@@_N@Z) qsslcontext_openssl.obj : error LNK2019: unresolved external symbol "struct ssl_method_st const * __cdecl q_SSLv3_server_method(void)" (?q_SSLv3_server_method@@YAPBUssl_method_st@@XZ) referenced in function "private: static void __cdecl QSslContext::initSslContext(class QSslContext *,enum QSslSocket::SslMode,class QSslConfiguration const &,bool)" (?initSslContext@QSslContext@@CAXPAV1@W4SslMode@QSslSocket@@ABVQSslConfiguration@@_N@Z) qsslsocket_openssl.obj : error LNK2019: unresolved external symbol "int __cdecl q_SSL_get_ex_new_index(long,void *,int (__cdecl*)(void *,void *,struct crypto_ex_data_st *,int,long,void *),int (__cdecl*)(struct crypto_ex_data_st *,struct crypto_ex_data_st *,void *,int,long,void *),void (__cdecl*)(void *,void *,struct crypto_ex_data_st *,int,long,void *))" (?q_SSL_get_ex_new_index@@YAHJPAXP6AH00PAUcrypto_ex_data_st@@HJ0@ZP6AH110HJ0@ZP6AX001HJ0@Z@Z) referenced in function "private: static bool __cdecl QSslSocketPrivate::ensureLibraryLoaded(void)" (?ensureLibraryLoaded@QSslSocketPrivate@@CA_NXZ) qsslsocket_openssl.obj : error LNK2019: unresolved external symbol "int __cdecl q_PKCS12_parse(struct PKCS12 *,char const *,struct evp_pkey_st * *,struct x509_st * *,struct stack_st_X509 * *)" (?q_PKCS12_parse@@YAHPAUPKCS12@@PBDPAPAUevp_pkey_st@@PAPAUx509_st@@PAPAUstack_st_X509@@@Z) referenced in function "public: static bool __cdecl QSslSocketBackendPrivate::importPkcs12(class QIODevice *,class QSslKey *,class QSslCertificate *,class QList<class QSslCertificate> *,class QByteArray const &)" (?importPkcs12@QSslSocketBackendPrivate@@SA_NPAVQIODevice@@PAVQSslKey@@PAVQSslCertificate@@PAV?$QList@VQSslCertificate@@@@ABVQByteArray@@@Z) qsslsocket_openssl.obj : error LNK2019: unresolved external symbol "struct PKCS12 * __cdecl q_d2i_PKCS12_bio(struct bio_st *,struct PKCS12 * *)" (?q_d2i_PKCS12_bio@@YAPAUPKCS12@@PAUbio_st@@PAPAU1@@Z) referenced in function "public: static bool __cdecl QSslSocketBackendPrivate::importPkcs12(class QIODevice *,class QSslKey *,class QSslCertificate *,class QList<class QSslCertificate> *,class QByteArray const &)" (?importPkcs12@QSslSocketBackendPrivate@@SA_NPAVQIODevice@@PAVQSslKey@@PAVQSslCertificate@@PAV?$QList@VQSslCertificate@@@@ABVQByteArray@@@Z) qsslsocket_openssl.obj : error LNK2019: unresolved external symbol "void __cdecl q_PKCS12_free(struct PKCS12 *)" (?q_PKCS12_free@@YAXPAUPKCS12@@@Z) referenced in function "public: static bool __cdecl QSslSocketBackendPrivate::importPkcs12(class QIODevice *,class QSslKey *,class QSslCertificate *,class QList<class QSslCertificate> *,class QByteArray const &)" (?importPkcs12@QSslSocketBackendPrivate@@SA_NPAVQIODevice@@PAVQSslKey@@PAVQSslCertificate@@PAV?$QList@VQSslCertificate@@@@ABVQByteArray@@@Z) ..\..\lib\Qt5Networkd.dll : fatal error LNK1120: 6 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x460' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.
Does anyone know what is causing this? I'm not sure if this is an error on my side or a bug in Qt.
Thanks,
Addison -
Hi this is just a guess, but have you tried to compile in Release mode instead of Debug?
-
I appreciate your help. I ended up trying what you said as well as adding a few more things to the configure command and it fixed my problem. I suspect that the actual issue was not debug versus release, but your idea got me on the right track.
First, remember you must clean the source code before calling configure again. Otherwise it won't work. From the git bash within the source directory, call this:
git submodule foreach --recursive "git clean -dfx"
Next, this is the configure command I used:
configure -platform win32-msvc2015 -release -ssl -openssl -opensource -nomake tests -nomake examples -L C:\OpenSSL-Win32\lib -I C:\OpenSSL-Win32\include -l libeay32 -l ssleay32
I believe the -l libeay32 and -l ssleay32 are what actually solved the problem but I am not entirely sure.
-
@Addison-Elliott said in Unable to build Qt 5.7 using MSVC 2015 - unresolved OpenSSL symbols:
I believe the -l libeay32 and -l ssleay32 are what actually solved the problem but I am not entirely sure.
yes indeed it is.
But i am confused why you even have to link against it. Normally it should rather try to load the libs dynamically.
And i also don't see the configuration flag to link against OpenSSL.