Error whie buildING qt 5.9 with openssl statically using VS2015



  • 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!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What version of OpenSSL did you download ?



  • Same issue, we used openSSL 1.0.2L


  • Lifetime Qt Champion

    Are you linking against a version of OpenSSL that is from the correct architecture ? And built using the same compiler ?




  • Lifetime Qt Champion

    Can you confirm that reverting it allows to build Qt statically with OpenSSL again ?



  • 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
         }
     }```

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.