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.8k 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #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
    • Cobra91151C Offline
      Cobra91151C Offline
      Cobra91151
      wrote on last edited by Cobra91151
      #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
      0
      • Cobra91151C Cobra91151

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

        Cobra91151C 1 Reply Last reply
        0
        • B Bernard Lowe

          @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

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on 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
          0
          • Cobra91151C Cobra91151

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

            Cobra91151C 1 Reply Last reply
            0
            • B Bernard Lowe

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

              Cobra91151C Offline
              Cobra91151C Offline
              Cobra91151
              wrote on 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
              1
              • Cobra91151C Cobra91151

                @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 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
                0
                • B Bernard Lowe

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

                  Cobra91151C 1 Reply Last reply
                  0
                  • B Bernard Lowe

                    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

                    Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on 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
                    1
                    • Cobra91151C Cobra91151

                      @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 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
                      • Cobra91151C Cobra91151

                        @SGaist

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

                        M Offline
                        M Offline
                        mcpp
                        wrote on last edited by
                        #21

                        @Cobra91151 How did you apply this patch? I'm getting errors

                        Cobra91151C 1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #22

                          @mcpp what exact errors ? What version of OpenSSL ?

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

                          1 Reply Last reply
                          0
                          • M mcpp

                            @Cobra91151 How did you apply this patch? I'm getting errors

                            Cobra91151C Offline
                            Cobra91151C Offline
                            Cobra91151
                            wrote on last edited by
                            #23

                            @mcpp

                            Hi! Please specify what issues with OpenSSL you encountered during Qt static compilation? I will try to help you.

                            1 Reply Last reply
                            0
                            • Cobra91151C Offline
                              Cobra91151C Offline
                              Cobra91151
                              wrote on last edited by
                              #24
                              This post is deleted!
                              1 Reply Last reply
                              0

                              • Login

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