Error while 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
         }
     }```


  • This post is deleted!


  • @flouwet @SGaist how do I apply this patch?



  • @flouwet I'm getting error: corrupt patch at line 33 when I save this patch in notepad++ and apply using git


  • Lifetime Qt Champion

    @mcpp
    There are several patches here, which one didn't apply correctly ?



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

  • Lifetime Qt Champion

    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.



  • @SGaist Okay I'll try that. Thanks for your help and amazing contribution to this source.



  • @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 externals

    My 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.


  • Lifetime Qt Champion

    Might be a silly question but: are you sure you are building in 64 bit mode ?



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


  • Lifetime Qt Champion

    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.


Log in to reply
 

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