Error while building qt 5.9 with openssl statically using VS2015
-
wrote on 30 Nov 2017, 06:39 last edited by aha_1980 3 Sept 2019, 18:44
I ran configure successfully using the following command:
configure -static -debug-and-release -prefix “C:\Qt\Qt5.9.2\static_with_openssl” -platform win32-msvc2015 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -sql-odbc -openssl-linked OPENSSL_PREFIX=C:\QtOpenSSL -I "C:\QtOpenSSL\include\openssl" -L "C:\QtOpenSSL\lib" -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests
it shows
OpenSSL ................................ yes Qt directly linked to OpenSSL ........ yes
but when I ran nmake, it shows:
ink /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /VERSION:5.9 /MANIFEST:embed /OUT:..\..\bin\xmlpatternsvalidator.exe @C:\Users\Antiver\AppData\Local\Temp\xmlpatternsvalidator.exe.13608.922.jom Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_num referenced in function "int __cdecl q_sk_num(struct stack_st *)" (?q_sk_num@@YAHPAUstack_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_value referenced in function "void * __cdecl q_sk_value(struct stack_st *,int)" (?q_sk_value@@YAPAXPAUstack_st@@H@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_new_null referenced in function "struct stack_st * __cdecl q_sk_new_null(void)" (?q_sk_new_null@@YAPAUstack_st@@XZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_free referenced in function "void __cdecl q_sk_free(struct stack_st *)" (?q_sk_free@@YAXPAUstack_st@@@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_pop_free referenced in function "void __cdecl q_sk_pop_free(struct stack_st *,void (__cdecl*)(void *))" (?q_sk_pop_free@@YAXPAUstack_st@@P6AXPAX@Z@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _sk_push referenced in function "void __cdecl q_sk_push(struct stack_st *,void *)" (?q_sk_push@@YAXPAUstack_st@@PAX@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _SSLeay_version referenced in function "char const * __cdecl q_SSLeay_version(int)" (?q_SSLeay_version@@YAPBDH@Z) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _SSLeay referenced in function "long __cdecl q_SSLeay(void)" (?q_SSLeay@@YAJXZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _CRYPTO_num_locks referenced in function "int __cdecl q_CRYPTO_num_locks(void)" (?q_CRYPTO_num_locks@@YAHXZ) Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "void __cdecl q_CRYPTO_set_locking_callback(void (__cdecl*)(int,int,char const *,int))" (?q_CRYPTO_set_locking_callback@@YAXP6AXHHPBDH@Z@Z) …… ..\..\bin\xmlpatterns.exe : fatal error LNK1120: 197 unresolved externals
Could you please tell me how to solve this problem?
Thanks! -
Hi and welcome to devnet,
What version of OpenSSL did you download ?
-
wrote on 15 Dec 2017, 12:24 last edited by
Same issue, we used openSSL 1.0.2L
-
Are you linking against a version of OpenSSL that is from the correct architecture ? And built using the same compiler ?
-
wrote on 18 Dec 2017, 16:39 last edited by flouwet
Yes, but i think the following commit is breaking my build.
https://code.qt.io/cgit/qt/qtbase.git/commit/src/network/ssl/ssl.pri?id=5e2367aaa5137f27c722cd7f8474696b0fbaa099 -
Can you confirm that reverting it allows to build Qt statically with OpenSSL again ?
-
wrote on 19 Dec 2017, 20:42 last edited by flouwet
I've got the build working with following patch.
diff --git a/src/network/configure.json b/src/network/configure.json index 1e08aa7..c9077c8 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -46,13 +46,24 @@ "-lproxy" ] }, - "openssl_headers": { - "label": "OpenSSL Headers", - "export": "openssl", - "test": "unix/openssl", - "sources": [ - { - "comment": "placeholder for OPENSSL_PATH", - "libs": "" - } - ] - }, "openssl": { + "label": "OpenSSL Libraries", + "export": "", - "label": "OpenSSL", - "test": "unix/openssl", "sources": [ { "type": "openssl" }, { + "comment": "placeholder for OPENSSL_LIBS{,_{DEBUG,RELEASE}}", - "comment": "placeholder for OPENSSL_{PATH,LIBS{,_{DEBUG,RELEASE}}}", "libs": "", "builds": { "debug": "", @@ -92,11 +103,6 @@ "test": "unix/ipv6ifname", "use": "network" }, + "openssl": { + "label": "OpenSSL", + "type": "compile", + "test": "unix/openssl" + }, "sctp": { "label": "SCTP support", "type": "compile", @@ -138,7 +144,7 @@ "enable": "input.openssl == 'yes' || input.openssl == 'linked' || input.openssl == 'runtime'", "disable": "input.openssl == 'no' || input.ssl == 'no'", "autoDetect": "!config.winrt", + "condition": "!features.securetransport && tests.openssl", - "condition": "!features.securetransport && (features.openssl-linked || libs.openssl_headers)", "output": [ "privateFeature", { "type": "publicQtConfig", "condition": "!features.openssl-linked" }, @@ -149,14 +155,9 @@ "label": " Qt directly linked to OpenSSL", "enable": "input.openssl == 'linked'", "disable": "input.openssl != 'linked'", + "condition": "features.openssl && libs.openssl", - "condition": "!features.securetransport && libs.openssl", "output": [ "privateFeature", + { "type": "varAssign", "name": "OPENSSL_LIBS", "value": "libs.openssl.libs", "eval": "true" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_DEBUG", "value": "libs.openssl.builds.debug.libs", + "eval": "true", "condition": "config.win32" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_RELEASE", "value": "libs.openssl.builds.release.libs", + "eval": "true", "condition": "config.win32" }, { "type": "define", "name": "QT_LINKED_OPENSSL" } ] }, diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 7935101..52ce2ee 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -56,7 +56,7 @@ qtConfig(ssl) { ssl/qsslellipticcurve_dummy.cpp } + qtConfig(openssl)|qtConfig(openssl-linked) { - qtConfig(openssl) { HEADERS += ssl/qsslcontext_openssl_p.h \ ssl/qsslsocket_openssl_p.h \ ssl/qsslsocket_openssl_symbols_p.h @@ -79,16 +79,10 @@ qtConfig(ssl) { # - libs in <OPENSSL_DIR>\lib\VC\static # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD" + include($$OUT_PWD/qtnetwork-config.pri) + + CONFIG(debug, debug|release) { + LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG + } else { + LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE + } + + QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS + LIBS_PRIVATE += $$OPENSSL_LIBS - qtConfig(openssl-linked): \ - QMAKE_USE_FOR_PRIVATE += openssl - else: \ - QMAKE_USE_FOR_PRIVATE += openssl/nolink win32: LIBS_PRIVATE += -lcrypt32 } }```
-
wrote on 5 Sept 2018, 08:17 last edited by Cobra91151 9 May 2018, 08:22This post is deleted!
-
I've got the build working with following patch.
diff --git a/src/network/configure.json b/src/network/configure.json index 1e08aa7..c9077c8 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -46,13 +46,24 @@ "-lproxy" ] }, - "openssl_headers": { - "label": "OpenSSL Headers", - "export": "openssl", - "test": "unix/openssl", - "sources": [ - { - "comment": "placeholder for OPENSSL_PATH", - "libs": "" - } - ] - }, "openssl": { + "label": "OpenSSL Libraries", + "export": "", - "label": "OpenSSL", - "test": "unix/openssl", "sources": [ { "type": "openssl" }, { + "comment": "placeholder for OPENSSL_LIBS{,_{DEBUG,RELEASE}}", - "comment": "placeholder for OPENSSL_{PATH,LIBS{,_{DEBUG,RELEASE}}}", "libs": "", "builds": { "debug": "", @@ -92,11 +103,6 @@ "test": "unix/ipv6ifname", "use": "network" }, + "openssl": { + "label": "OpenSSL", + "type": "compile", + "test": "unix/openssl" + }, "sctp": { "label": "SCTP support", "type": "compile", @@ -138,7 +144,7 @@ "enable": "input.openssl == 'yes' || input.openssl == 'linked' || input.openssl == 'runtime'", "disable": "input.openssl == 'no' || input.ssl == 'no'", "autoDetect": "!config.winrt", + "condition": "!features.securetransport && tests.openssl", - "condition": "!features.securetransport && (features.openssl-linked || libs.openssl_headers)", "output": [ "privateFeature", { "type": "publicQtConfig", "condition": "!features.openssl-linked" }, @@ -149,14 +155,9 @@ "label": " Qt directly linked to OpenSSL", "enable": "input.openssl == 'linked'", "disable": "input.openssl != 'linked'", + "condition": "features.openssl && libs.openssl", - "condition": "!features.securetransport && libs.openssl", "output": [ "privateFeature", + { "type": "varAssign", "name": "OPENSSL_LIBS", "value": "libs.openssl.libs", "eval": "true" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_DEBUG", "value": "libs.openssl.builds.debug.libs", + "eval": "true", "condition": "config.win32" }, + { "type": "varAssign", "name": "OPENSSL_LIBS_RELEASE", "value": "libs.openssl.builds.release.libs", + "eval": "true", "condition": "config.win32" }, { "type": "define", "name": "QT_LINKED_OPENSSL" } ] }, diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 7935101..52ce2ee 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -56,7 +56,7 @@ qtConfig(ssl) { ssl/qsslellipticcurve_dummy.cpp } + qtConfig(openssl)|qtConfig(openssl-linked) { - qtConfig(openssl) { HEADERS += ssl/qsslcontext_openssl_p.h \ ssl/qsslsocket_openssl_p.h \ ssl/qsslsocket_openssl_symbols_p.h @@ -79,16 +79,10 @@ qtConfig(ssl) { # - libs in <OPENSSL_DIR>\lib\VC\static # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD" + include($$OUT_PWD/qtnetwork-config.pri) + + CONFIG(debug, debug|release) { + LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG + } else { + LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE + } + + QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS + LIBS_PRIVATE += $$OPENSSL_LIBS - qtConfig(openssl-linked): \ - QMAKE_USE_FOR_PRIVATE += openssl - else: \ - QMAKE_USE_FOR_PRIVATE += openssl/nolink win32: LIBS_PRIVATE += -lcrypt32 } }```
-
@mcpp
There are several patches here, which one didn't apply correctly ? -
wrote on 10 Mar 2019, 12:44 last edited by
@SGaist I copied the patch from the window. Here is what I brought to the editor. Its says corrupt patch at line 33. I assume I'm just doing something wrong. Any advice?
diff --git a/src/network/configure.json b/src/network/configure.json
index 1e08aa7..c9077c8 100644
--- a/src/network/configure.json
+++ b/src/network/configure.json
@@ -46,13 +46,24 @@
"-lproxy"
]
},-
"openssl_headers": {
-
"label": "OpenSSL Headers",
-
"export": "openssl",
-
"test": "unix/openssl",
-
"sources": [
-
{
-
"comment": "placeholder for OPENSSL_PATH",
-
"libs": ""
-
}
-
]
-
}, "openssl": {
-
"label": "OpenSSL Libraries",
-
"export": "",
-
"label": "OpenSSL",
-
"test": "unix/openssl", "sources": [ { "type": "openssl" }, {
-
"comment": "placeholder for OPENSSL_LIBS{,_{DEBUG,RELEASE}}",
-
"comment": "placeholder for OPENSSL_{PATH,LIBS{,_{DEBUG,RELEASE}}}", "libs": "", "builds": { "debug": "",
@@ -92,11 +103,6 @@
"test": "unix/ipv6ifname",
"use": "network"
},-
"openssl": {
-
"label": "OpenSSL",
-
"type": "compile",
-
"test": "unix/openssl"
-
}, "sctp": { "label": "SCTP support", "type": "compile",
@@ -138,7 +144,7 @@
"enable": "input.openssl == 'yes' || input.openssl == 'linked' || input.openssl == 'runtime'",
"disable": "input.openssl == 'no' || input.ssl == 'no'",
"autoDetect": "!config.winrt",-
"condition": "!features.securetransport && tests.openssl",
-
"condition": "!features.securetransport && (features.openssl-linked || libs.openssl_headers)", "output": [ "privateFeature", { "type": "publicQtConfig", "condition": "!features.openssl-linked" },
@@ -149,14 +155,9 @@
"label": " Qt directly linked to OpenSSL",
"enable": "input.openssl == 'linked'",
"disable": "input.openssl != 'linked'",-
"condition": "features.openssl && libs.openssl",
-
"condition": "!features.securetransport && libs.openssl", "output": [ "privateFeature",
-
{ "type": "varAssign", "name": "OPENSSL_LIBS", "value": "libs.openssl.libs", "eval": "true" },
-
{ "type": "varAssign", "name": "OPENSSL_LIBS_DEBUG", "value": "libs.openssl.builds.debug.libs",
-
"eval": "true", "condition": "config.win32" },
-
{ "type": "varAssign", "name": "OPENSSL_LIBS_RELEASE", "value": "libs.openssl.builds.release.libs",
-
"eval": "true", "condition": "config.win32" }, { "type": "define", "name": "QT_LINKED_OPENSSL" } ] },
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 7935101..52ce2ee 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -56,7 +56,7 @@ qtConfig(ssl) {
ssl/qsslellipticcurve_dummy.cpp
}- qtConfig(openssl)|qtConfig(openssl-linked) {
- qtConfig(openssl) {
HEADERS += ssl/qsslcontext_openssl_p.h
ssl/qsslsocket_openssl_p.h
ssl/qsslsocket_openssl_symbols_p.h
@@ -79,16 +79,10 @@ qtConfig(ssl) {
# - libs in <OPENSSL_DIR>\lib\VC\static
# - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD"
-
include($$OUT_PWD/qtnetwork-config.pri)
-
CONFIG(debug, debug|release) {
-
LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG
-
} else {
-
LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE
-
}
-
QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS
-
LIBS_PRIVATE += $$OPENSSL_LIBS
-
qtConfig(openssl-linked): \
-
QMAKE_USE_FOR_PRIVATE += openssl
-
else: \
-
}QMAKE_USE_FOR_PRIVATE += openssl/nolink win32: LIBS_PRIVATE += -lcrypt32
}```
-
-
You didn't do something wrong. The files the original patches were applied to changed in between.
You can also simply compare the content of the files with the modifications and apply them by hand.
-
You didn't do something wrong. The files the original patches were applied to changed in between.
You can also simply compare the content of the files with the modifications and apply them by hand.
-
You didn't do something wrong. The files the original patches were applied to changed in between.
You can also simply compare the content of the files with the modifications and apply them by hand.
wrote on 11 Mar 2019, 15:03 last edited by@SGaist Okay It seems to be getting a bit further, however I am getting this error now:
libeay32MT.lib(gost_eng.obj) : error LNK2019: unresolved external symbol __iob_func referenced in function bind_gost
libeay32MT.lib(ui_openssl.obj) : error LNK2001: unresolved external symbol __iob_func
ssleay32MT.lib(t1_enc.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(txt_db.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(e_capi.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(cryptlib.obj) : error LNK2019: unresolved external symbol sscanf referenced in function OPENSSL_cpuid_setup
libeay32MT.lib(v3_utl.obj) : error LNK2001: unresolved external symbol sscanf
libeay32MT.lib(cryptlib.obj) : error LNK2019: unresolved external symbol _vsnwprintf referenced in function OPENSSL_showfatal
....\bin\xmlpatterns.exe : fatal error LNK1120: 3 unresolved externalsMy config is:
configure -static -debug-and-release -prefix “C:\Qt\Qt5.9.2\static_with_openssl” -platform win32-msvc2015 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -sql-odbc -openssl-linked -I "C:\Program Files\OpenSSL-Win64\include" -L "C:\Program Files\OpenSSL-Win64\lib\VC\static" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests
Any ideas? I'm building with VS2015.
-
Might be a silly question but: are you sure you are building in 64 bit mode ?
-
wrote on 14 Mar 2019, 13:00 last edited by
I am. I think its a version compatibility issue with ssl. It should be built with vs2015. Even though those say 32MT, I think the problem is that they are built with vs2013. I built these with vs2015 and tried again, and got these:
Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol sk_num referenced in function "int __cdecl q_sk_num(struct stack_st *)" (?q_sk_num@@YAHPEAUstack_st@@@Z)
Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol sk_value referenced in function "void * __cdecl q_sk_value(struct stack_st *,int)" (?q_sk_value@@YAPEAXPEAUstack_st@@H@Z)
Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol sk_new_null referenced in function "struct stack_st * __cdecl q_sk_new_null(void)" (?q_sk_new_null@@YAPEAUstack_st@@XZ)
Qt5Network.lib(qsslsocket_openssl_symbols.obj) : error LNK2019: unresolved external symbol sk_free referenced in function "void __cdecl q_sk_free(struct stack_st *)" (?q_sk_free@@YAXPEAUstack_st@@@Z)And about 500 others.
What libs should I be building using vs2015 for openssl?
-
Well, OpenSSL itself.
You can't mix and match C++ libraries built with different compilers on Windows. The only exception currently is VS2017 which is backward compatible with VS2015.
-
wrote on 15 Nov 2019, 09:55 last edited by
Had the same unresolved errors by using Visual2017, Qt5.9.8, having an own compiled static OpenSSL-libs, so this could not be the mentioned compatibility problem.
Lately I found out that the unresolved was not caused by linking the Qt5Network.lib, because this was already created on the disk. The lib that caused the error was the xmlpatters-lib, and when I removed it from compiling by using -skip xmlpatterns in the config command, everythign went fine!
So my final command wasC:\Qt\Qt5.9.8\5.9.8\Src\configure.bat -release -static -static-runtime -prefix C:\Qt\Qt5.9.8_static_ssl −opengl desktop -skip webengine -skip xmlpatterns -nomake tests -nomake examples -openssl -openssl-linked -I C:\OpenSSL\include -L C:\OpenSSL\lib
by having the three environment variables OPENSSL_LIBS, OPENSSL_LIBS_DEBUG and OPENSSL_LIBS_RELEASE already set via windows system settings. Setting them directly in the command line caused syntax errors (probably only supported by earlier Configure-versions?)