Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt static with OpenSSL issue
Forum Updated to NodeBB v4.3 + New Features

Qt static with OpenSSL issue

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 4 Posters 5.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cobra91151
    wrote on 5 Sept 2018, 12:49 last edited by Cobra91151 9 May 2018, 12:51
    #1

    Hi! I want to build Qt statically with OpenSSL. I have set up the batch file:

    SET /P qtBuildType=Qt build type (shared/static): 
    SET /P qtBuildMySqlIncludePath=MySql include path: 
    SET /P qtBuildMySqlLibPath=MySql lib path: 
    SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: 
    SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: 
    SET /P qtBuildPath=Enter Qt build path: 
    configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" -prefix "%qtBuildPath%"
    

    It works well, but then I get issue:

    ..\..\bin\xmlpatterns.exe : fatal error LNK1120: 197 unresolved externals
    jom: D:\QtBuild\Src\qtxmlpatterns\tools\xmlpatterns\Makefile.Release [..\..\bin\xmlpatterns.exe] Error 1120
    jom: D:\QtBuild\Src\qtxmlpatterns\tools\xmlpatterns\Makefile [release] Error 2
    jom: D:\QtBuild\Src\qtxmlpatterns\tools\Makefile [sub-xmlpatterns-make_first] Error 2
    jom: D:\QtBuild\Src\qtxmlpatterns\tools\Makefile [sub-xmlpatternsvalidator-make_first] Error 2
    jom: D:\QtBuild\Src\qtxmlpatterns\Makefile [sub-tools-make_first] Error 2
    jom: D:\QtBuild\Src\Makefile [module-qtxmlpatterns-make_first] Error 2
    

    Screenshot:

    0_1536151471731_2018-09-05_154409.png

    I have tried different OpenSSL versions but the issue still exists. I have found the similar issue here: https://forum.qt.io/topic/85501/error-whie-building-qt-5-9-with-openssl-statically-using-vs2015/8

    But I can't find the patch files. Where can I get the patch? Thank you.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Sept 2018, 21:06 last edited by
      #2

      Hi,

      The patch is embedded in the post on that thread.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 5 Sept 2018, 21:10
      0
      • S SGaist
        5 Sept 2018, 21:06

        Hi,

        The patch is embedded in the post on that thread.

        C Offline
        C Offline
        Cobra91151
        wrote on 5 Sept 2018, 21:10 last edited by
        #3

        @SGaist

        Hi! So there are no actual patch files, only embedded code in the post? Thanks.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 5 Sept 2018, 21:21 last edited by
          #4

          The post contains the patch. Copy the content in a file and then you can apply it.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 2 Replies Last reply 5 Sept 2018, 21:33
          0
          • S SGaist
            5 Sept 2018, 21:21

            The post contains the patch. Copy the content in a file and then you can apply it.

            C Offline
            C Offline
            Cobra91151
            wrote on 5 Sept 2018, 21:33 last edited by
            #5

            @SGaist

            Ok. I will try the patch and reply later. Thanks.

            M 1 Reply Last reply 9 Mar 2019, 15:06
            0
            • S SGaist
              5 Sept 2018, 21:21

              The post contains the patch. Copy the content in a file and then you can apply it.

              C Offline
              C Offline
              Cobra91151
              wrote on 6 Sept 2018, 12:57 last edited by Cobra91151 9 Jun 2018, 12:58
              #6

              @SGaist

              Hi! I have tried it but I get issue:

              0_1536238582630_2018-09-06_155549.png

              I think there is a syntax error in the file. I will check it.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 6 Sept 2018, 12:59 last edited by
                #7

                Did you do the build from a clean state ?

                In anywise, you should use out of source builds, so if something goes wrong, you can juste nuke the folder and start again.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                C 1 Reply Last reply 6 Sept 2018, 13:13
                0
                • S SGaist
                  6 Sept 2018, 12:59

                  Did you do the build from a clean state ?

                  In anywise, you should use out of source builds, so if something goes wrong, you can juste nuke the folder and start again.

                  C Offline
                  C Offline
                  Cobra91151
                  wrote on 6 Sept 2018, 13:13 last edited by
                  #8

                  @SGaist

                  Yes, I have a zip copy and delete old src dir and extract the new every time the build fails. So it is a clean state. I validated json using the https://jsonlint.com service and it displays errors:

                  0_1536239353418_2018-09-06_160825.png

                  So it contains syntax errors. It's messy to write it all (patch) to config/pri files, better would be replace the files. I will try to fix these errors.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Cobra91151
                    wrote on 6 Sept 2018, 13:53 last edited by
                    #9

                    Now it fails with the error:

                    Info: creating super cache file D:\QtBuild\Src\.qmake.super
                    D:/QtBuild/Src/qtbase/mkspecs/features/qt_configure.prf:1941: Error parsing JSON at 411:41: unterminated array
                    Project ERROR: Invalid or non-existent file D:/QtBuild/Src/qtbase/src/network/configure.json.
                    

                    I will disable the xmlpatterns and try again.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Cobra91151
                      wrote on 6 Sept 2018, 14:55 last edited by
                      #10

                      It fails with another issue:

                      0_1536245574428_2018-09-06_175240.png

                      I use Win32 OpenSSL v1.0.2p. I will try different version: Win32OpenSSL-1_0_2L.

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        Cobra91151
                        wrote on 6 Sept 2018, 15:20 last edited by Cobra91151 9 Jun 2018, 15:24
                        #11

                        The same issue still exists with Win32OpenSSL-1_0_2L:

                        0_1536247176588_2018-09-06_181909.png

                        I use Qt 5.9.6. Has anyone build Qt 5.9.6 statically with OpenSSL successfully? I think the problem is with Qt, not the OpenSSL libs. Thanks.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Cobra91151
                          wrote on 6 Sept 2018, 17:11 last edited by Cobra91151 9 Jun 2018, 17:15
                          #12

                          I was wrong. I came across this issue: https://bugreports.qt.io/browse/QTBUG-58024
                          The problem was with the OpenSSL libs. I have downloaded OpenSSL v1.0.2l (stable) for VS 2017 from the website: https://www.npcglib.org/~stathis/blog/precompiled-openssl/

                          Extracted it, and added to the include/libs path in my batch file. Now it compiles without errors:

                          SET /P qtBuildType=Qt build type (shared/static): 
                          SET /P qtBuildMySqlIncludePath=MySql include path: 
                          SET /P qtBuildMySqlLibPath=MySql lib path: 
                          SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: 
                          SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: 
                          SET /P qtBuildPath=Enter Qt build path: 
                          configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
                          

                          0_1536253934336_2018-09-06_191732.png

                          B 1 Reply Last reply 15 Oct 2018, 19:50
                          0
                          • C Cobra91151
                            6 Sept 2018, 17:11

                            I was wrong. I came across this issue: https://bugreports.qt.io/browse/QTBUG-58024
                            The problem was with the OpenSSL libs. I have downloaded OpenSSL v1.0.2l (stable) for VS 2017 from the website: https://www.npcglib.org/~stathis/blog/precompiled-openssl/

                            Extracted it, and added to the include/libs path in my batch file. Now it compiles without errors:

                            SET /P qtBuildType=Qt build type (shared/static): 
                            SET /P qtBuildMySqlIncludePath=MySql include path: 
                            SET /P qtBuildMySqlLibPath=MySql lib path: 
                            SET /P qtBuildOpenSSLIncludePath=OpenSSL include path: 
                            SET /P qtBuildOpenSSLLibPath=OpenSSL lib path: 
                            SET /P qtBuildPath=Enter Qt build path: 
                            configure.bat -debug-and-release -%qtBuildType% -opensource -nomake tools -nomake examples -no-ltcg -sql-mysql -I "%qtBuildMySqlIncludePath%" -L "%qtBuildMySqlLibPath%" -ssl -openssl -openssl-linked -I "%qtBuildOpenSSLIncludePath%" -L "%qtBuildOpenSSLLibPath%" OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MTd -llibeay32MTd" OPENSSL_LIBS_RELEASE="-lssleay32MT -llibeay32MT" -prefix "%qtBuildPath%"
                            

                            0_1536253934336_2018-09-06_191732.png

                            B Offline
                            B Offline
                            Bernard Lowe
                            wrote on 15 Oct 2018, 19:50 last edited by
                            #13

                            @Cobra91151 I followed these steps which lead to a successful compilation. Now, however, my application crashes immediately after launch. Have you seen anything like this? Thanks

                            C 1 Reply Last reply 16 Oct 2018, 20:25
                            0
                            • B Bernard Lowe
                              15 Oct 2018, 19:50

                              @Cobra91151 I followed these steps which lead to a successful compilation. Now, however, my application crashes immediately after launch. Have you seen anything like this? Thanks

                              C Offline
                              C Offline
                              Cobra91151
                              wrote on 16 Oct 2018, 20:25 last edited by Cobra91151
                              #14

                              @Bernard-Lowe

                              Hi! What is your compiler? Try to attach the debugger to the application and check again. By the way, check my Qt static with MySQL issue here: https://forum.qt.io/topic/94378/qt-static-with-mysql-issue/33 to get more information about Qt static compilation.

                              B 1 Reply Last reply 16 Oct 2018, 23:18
                              0
                              • C Cobra91151
                                16 Oct 2018, 20:25

                                @Bernard-Lowe

                                Hi! What is your compiler? Try to attach the debugger to the application and check again. By the way, check my Qt static with MySQL issue here: https://forum.qt.io/topic/94378/qt-static-with-mysql-issue/33 to get more information about Qt static compilation.

                                B Offline
                                B Offline
                                Bernard Lowe
                                wrote on 16 Oct 2018, 23:18 last edited by Bernard Lowe
                                #15

                                @Cobra91151 Hello! Thanks for your comprehensive response. My compiler is VS 2017 (linked with OpenSSL v1.0.2l). I had a debugger attached (cdb.exe) through qtcreator which would detatch the debugger before the main entry point. I am on openssl 'l' so your post could be very relevant here so I'll explore after trying one more thing:
                                One major oops that I had just realized was that I left in MD instead of MT after setting -static-runtime in configure so I am trying with MT now.

                                C 1 Reply Last reply 17 Oct 2018, 06:46
                                0
                                • B Bernard Lowe
                                  16 Oct 2018, 23:18

                                  @Cobra91151 Hello! Thanks for your comprehensive response. My compiler is VS 2017 (linked with OpenSSL v1.0.2l). I had a debugger attached (cdb.exe) through qtcreator which would detatch the debugger before the main entry point. I am on openssl 'l' so your post could be very relevant here so I'll explore after trying one more thing:
                                  One major oops that I had just realized was that I left in MD instead of MT after setting -static-runtime in configure so I am trying with MT now.

                                  C Offline
                                  C Offline
                                  Cobra91151
                                  wrote on 17 Oct 2018, 06:46 last edited by Cobra91151
                                  #16

                                  @Bernard-Lowe

                                  Hi! Try compiling Qt with SSL /MT libs and reply. By the way, you can check if it work with Visual Studio before compiling Qt. By creating simple console project:

                                  Code:

                                  #include <iostream>
                                  #include <openssl/bio.h>
                                  #include <openssl/ssl.h>
                                  #include <openssl/err.h>
                                  using namespace std;
                                  
                                  int main()
                                  {
                                  	cout << "Hello World!" << endl;
                                  	SSL_load_error_strings();
                                  	ERR_load_BIO_strings();
                                  	OpenSSL_add_all_algorithms();
                                          system("Pause");
                                          return 0;
                                  }
                                  

                                  Don't forget to add all the OpenSSL includes/libs to VS 2017 and change Runtime library to Multi-threaded (/MT) (as Release) in Code Generation section.

                                  B 1 Reply Last reply 17 Oct 2018, 14:13
                                  1
                                  • C Cobra91151
                                    17 Oct 2018, 06:46

                                    @Bernard-Lowe

                                    Hi! Try compiling Qt with SSL /MT libs and reply. By the way, you can check if it work with Visual Studio before compiling Qt. By creating simple console project:

                                    Code:

                                    #include <iostream>
                                    #include <openssl/bio.h>
                                    #include <openssl/ssl.h>
                                    #include <openssl/err.h>
                                    using namespace std;
                                    
                                    int main()
                                    {
                                    	cout << "Hello World!" << endl;
                                    	SSL_load_error_strings();
                                    	ERR_load_BIO_strings();
                                    	OpenSSL_add_all_algorithms();
                                            system("Pause");
                                            return 0;
                                    }
                                    

                                    Don't forget to add all the OpenSSL includes/libs to VS 2017 and change Runtime library to Multi-threaded (/MT) (as Release) in Code Generation section.

                                    B Offline
                                    B Offline
                                    Bernard Lowe
                                    wrote on 17 Oct 2018, 14:13 last edited by
                                    #17

                                    @Cobra91151
                                    Your spike solution worked perfectly, it was also quite revealing because after succeeding using https://www.npcglib.org/~stathis/blog/precompiled-openssl/ MT libs with static runtime in Visual Studio, I attempted to use the MD libs and the linker attempted to look for a ssleay32MD DLL as if it was a windows system library which was not expected behavior for me.

                                    My build did not fare as well because I was attempting to use https://slproweb.com/products/Win32OpenSSL.html libraries. I will now try npcg lib with MT and static runtime set. Crossing my fingers.

                                    Here was my configure command on that last failed build using slproweb libs

                                    configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib\VC\static OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib"
                                    
                                    B 1 Reply Last reply 17 Oct 2018, 15:34
                                    0
                                    • B Bernard Lowe
                                      17 Oct 2018, 14:13

                                      @Cobra91151
                                      Your spike solution worked perfectly, it was also quite revealing because after succeeding using https://www.npcglib.org/~stathis/blog/precompiled-openssl/ MT libs with static runtime in Visual Studio, I attempted to use the MD libs and the linker attempted to look for a ssleay32MD DLL as if it was a windows system library which was not expected behavior for me.

                                      My build did not fare as well because I was attempting to use https://slproweb.com/products/Win32OpenSSL.html libraries. I will now try npcg lib with MT and static runtime set. Crossing my fingers.

                                      Here was my configure command on that last failed build using slproweb libs

                                      configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib\VC\static OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib"
                                      
                                      B Offline
                                      B Offline
                                      Bernard Lowe
                                      wrote on 17 Oct 2018, 15:34 last edited by
                                      #18

                                      Failed on unresolved external errors akin to below:

                                      libeay32MT.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp_CreateCompatibleBitmap referenced in function readscreen
                                      

                                      It looks like i need to link in GDI as well according to this Stack Overflow post

                                      C 1 Reply Last reply 17 Oct 2018, 17:50
                                      0
                                      • B Bernard Lowe
                                        17 Oct 2018, 15:34

                                        Failed on unresolved external errors akin to below:

                                        libeay32MT.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp_CreateCompatibleBitmap referenced in function readscreen
                                        

                                        It looks like i need to link in GDI as well according to this Stack Overflow post

                                        C Offline
                                        C Offline
                                        Cobra91151
                                        wrote on 17 Oct 2018, 17:50 last edited by
                                        #19

                                        @Bernard-Lowe

                                        You need to specify additional libs to configure. I have the batch file for Qt compilation. For example, you need:

                                        Debug: OPENSSL_LIBS="-llibeay32MTd -lssleay32MTd -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"

                                        Release: OPENSSL_LIBS="-llibeay32MT -lssleay32MT -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"

                                        B 1 Reply Last reply 17 Oct 2018, 21:48
                                        1
                                        • C Cobra91151
                                          17 Oct 2018, 17:50

                                          @Bernard-Lowe

                                          You need to specify additional libs to configure. I have the batch file for Qt compilation. For example, you need:

                                          Debug: OPENSSL_LIBS="-llibeay32MTd -lssleay32MTd -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"

                                          Release: OPENSSL_LIBS="-llibeay32MT -lssleay32MT -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"

                                          B Offline
                                          B Offline
                                          Bernard Lowe
                                          wrote on 17 Oct 2018, 21:48 last edited by
                                          #20

                                          @Cobra91151 Wish that I saw your note earlier. I got it to work using this configure:

                                          configure -prefix C:\Qt\5.11.2_openssl -mp -debug-and-release -opengl desktop -opensource -static -static-runtime -opensource -confirm-license -no-icu -no-sql-sqlite -no-qml-debug -nomake examples -nomake tests -skip qtactiveqt -skip qtserialport -skip qtquickcontrols -skip qtsensors -skip qtlocation -skip qtscript -platform win32-msvc -openssl-linked -I C:\Development\openssl-1.0.2l-vs2017\include64 -L C:\Development\openssl-1.0.2l-vs2017\lib64 OPENSSL_LIBS_DEBUG="libeay32MTd.lib ssleay32MTd.lib gdi32.lib User32.lib" OPENSSL_LIBS_RELEASE="libeay32MT.lib ssleay32MT.lib gdi32.lib User32.lib"
                                          
                                          1 Reply Last reply
                                          1

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved