Building Qt5 with OpenSSL support using VS 2015
-
@jsulm tried it, no luck. This Static building thing is really getting tiring now, its been 2 days that I've been trying to get it to work. Would be nice if Qt had some tool to check for pre-requisities, paths, directories etc. Because the errors themselves are very non-descriptive so you just have to google and try to figure out what's causing failures.
E.g. Currently, I'm trying building in the sources folder and now i"m getting unresolved external symbols related to openssl. I checked several examples and my configure options are correct, openssl static lib is present in the correct folder, tried downloading pre-built openssl lib as well as generating my own lib, still getting the same openssl error.
Qt version: 5.12.0
MSVC2017
Openssl 1.1.1aconfigure.bat -commercial -static -debug-and-release -prefix C:\Qt\Static\5.12.0 -platform win32-msvc2017 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-odbc -sql-sqlite -make libs -nomake tools -nomake examples -nomake tests OPENSSL_LIBS="-llibssl -llibcrypto" -openssl-linked -I c:/openssl/build32/include -L c:/openssl/build32/lib
Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DSA_new referenced in functi on "struct dsa_st * __cdecl q_DSA_new(void)" (?q_DSA_new@@YAPAUdsa_st@@XZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DSA_free referenced in funct ion "void __cdecl q_DSA_free(struct dsa_st *)" (?q_DSA_free@@YAXPAUdsa_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DSA_bits referenced in funct ion "int __cdecl q_DSA_bits(struct dsa_st *)" (?q_DSA_bits@@YAHPAUdsa_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _RSA_new referenced in functi on "struct rsa_st * __cdecl q_RSA_new(void)" (?q_RSA_new@@YAPAUrsa_st@@XZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _RSA_bits referenced in funct ion "int __cdecl q_RSA_bits(struct rsa_st *)" (?q_RSA_bits@@YAHPAUrsa_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _RSA_free referenced in funct ion "void __cdecl q_RSA_free(struct rsa_st *)" (?q_RSA_free@@YAXPAUrsa_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DH_new referenced in functio n "struct dh_st * __cdecl q_DH_new(void)" (?q_DH_new@@YAPAUdh_st@@XZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DH_free referenced in functi on "void __cdecl q_DH_free(struct dh_st *)" (?q_DH_free@@YAXPAUdh_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DH_bits referenced in functi on "int __cdecl q_DH_bits(struct dh_st *)" (?q_DH_bits@@YAHPAUdh_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DH_check referenced in funct ion "int __cdecl q_DH_check(struct dh_st *,int *)" (?q_DH_check@@YAHPAUdh_st@@PAH@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _d2i_DHparams referenced in f unction "struct dh_st * __cdecl q_d2i_DHparams(struct dh_st * *,unsigned char const * *,long)" (?q_d2i_DHparams@@YAPAUdh _st@@PAPAU1@PAPBEJ@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _i2d_DHparams referenced in f unction "int __cdecl q_i2d_DHparams(struct dh_st *,unsigned char * *)" (?q_i2d_DHparams@@YAHPAUdh_st@@PAPAE@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _DH_get0_pqg referenced in fu nction "void __cdecl q_DH_get0_pqg(struct dh_st const *,struct bignum_st const * *,struct bignum_st const * *,struct big num_st const * *)" (?q_DH_get0_pqg@@YAXPBUdh_st@@PAPBUbignum_st@@11@Z) ..\..\..\bin\canbusutil.exe : fatal error LNK1120: 244 unresolved externals jom: C:\Qt\Static\qt-everywhere-src-5.12.0\qtserialbus\src\tools\canbusutil\Makefile.Release [..\..\..\bin\canbusutil.ex e] Error 1120 jom: C:\Qt\Static\qt-everywhere-src-5.12.0\qtserialbus\src\tools\canbusutil\Makefile [release] Error 2 jom: C:\Qt\Static\qt-everywhere-src-5.12.0\qtserialbus\src\tools\Makefile [sub-canbusutil-make_first] Error 2 jom: C:\Qt\Static\qt-everywhere-src-5.12.0\qtserialbus\src\Makefile [sub-tools-make_first] Error 2 jom: C:\Qt\Static\qt-everywhere-src-5.12.0\qtserialbus\Makefile [sub-src-make_first] Error 2 jom: C:\Qt\Static\qt-everywhere-src-5.12.0\Makefile [module-qtserialbus-make_first] Error 2
-
Are you building for 64 or 32 bit target architecture?
And since you've a commercial license you could ask the Qt Company for help. -
@Christian-Ehrlicher said in Building Qt5 with OpenSSL support using VS 2015:
Are you building for 64 or 32 bit target architecture?
And since you've a commercial license you could ask the Qt Company for help.32-bit.
I'm currently evaluating QT for our commercial software, thought the setup would be straightforward but keep running into one issue after another, so treating it as learning process - still frustrating though.
-
Can you show us the link line of Qt5Network.lib? Must be directly above the linker errors.
-
Finally, got it working! Re-set everything again, unzipped fresh sources etc and used this configure...
configure -commercial -static -debug-and-release -prefix C:\Qt\Static\5.12.0 -platform win32-msvc2017 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-odbc -sql-sqlite -make libs -nomake tools -nomake examples -nomake tests -openssl-linked OPENSSL_LIBS="-llibssl -llibcrypto" -I c:\openssl\build32\include -L c:\openssl\build32\lib
not sure if moving openssl-linked ahead made any difference, but I'll just save these settings and stick with them.
Now, how do I update my Visual studio project to link QT statically?
-
Still working on the static environment setup, getting whole bunch of unresolved external errors. The build config is Win32, which is inline with static qt win32 build. also double checked and QT libs are added as Additional libraries in project settings.
In the image below, first two errors are related to an internal lib. The remaining errors are all unresolved externals. I did go through an interesting checklist here (https://heejune.me/2015/12/03/resolving-the-lnk2019-error-while-link-qt-app/) and don't see anything that applies to my config.
-
Hi,
Might be a silly question but why are you using the VS2017 mkspec for VS2015 ?
-
@SGaist I moved to VS17 because I was getting corecrt errors while building QT.
Two unresolved errors were solved by adding ws2_32.lib. Also, went into Qt Project Settings - Qt Modules and checked a whole bunch of modules. Now I'm getting only one linker error. Maybe its related to the two E2512 errors?
-
I've managed to fix the preprocessor error but still not able to figure out linker error. Weird thing is that I've tried compiling my app by linking dynamically with QT (default config) and even that is giving out the same error, so its probably not something specific to static linking with QT.
Last time my project was compiling successfully in VS2015 against qt dlls. Uninstalled VS2015, installed VS2017 and now seeing this linker error. Any tips?
-
Fixed my compilation issue and also Found a Bug in Qt.
Repro: In Visual Studio. Go to Qt VS Tools -> Qt Project Settings -> Qt Modules (Tab) and make changes. This will add
\ $(INHERIT)\
into the project's Linker -> Additional Dependencies. Removing the slashes solved the problem. No wonder I couldn't figure out what the object file was when I was getting ".obj" error during compilation.
-
cd examples\ && ( if not exist Makefile C:\Qt\Static\qt-everywhere-src-5.12.0\qtbase\bin\qmake.exe -o Makefile C :\Qt\Static\qt-everywhere-src-5.12.0\qtnetworkauth\examples\examples.pro ) && "C:\Program Files (x86)\Microsoft Visual S tudio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe" -f Makefile distclean ASSERT: "fileName.isEmpty() || isAbsolutePath(fileName)" in file C:\Qt\Static\qt-everywhere-src-5.12.0\qtbase\qmake\libr ary\ioutils.cpp, line 53 NMAKE : fatal error U1077: 'cd' : return code '0x40000015' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.
When I run nmake distclean in sources folder, its keeps running for a while and eventually ends with this error. I built Qt with "nomake examples" flag, is that the reason? Do I need to unzip fresh sources again or can I just ignore this and continue by calling configure and jom?
-
No, examples are just normal projects. You can open them in Qt Creator and build them from there.