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. how to compile qt static with open ssl

how to compile qt static with open ssl

Scheduled Pinned Locked Moved Unsolved General and Desktop
compiler errorstaticopenssl
22 Posts 3 Posters 15.1k Views
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    The config log is not readable.

    In any case, you should check the test logs to see why the OpenSSL related tests failed.

    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
    • S Offline
      S Offline
      SherifOmran
      wrote on last edited by
      #3

      I am running win7 and I noticed the following :
      giving this command runs

      configure.bat -release -opensource -confirm-license -opengl dynamic -platform win32-msvc2015 -openssl -I C:\OpenSSL\include -L c:\OpenSSL\lib -nomake examples -nomake tests -no-direct2d -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtquickcontrols -skip qtquickcontrols2 -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns -static -static-runtime  -openssl-linked
      

      but when i add the following , i get the error message above

      OPENSSL_LIBS="-LC:\OpenSSL\lib -lssl -lcrypto"
      

      what is this? some threads state we should use this OPENSSL_LIBS="-llibeay32 -lssleay32" but i am lost and i get the same error with both.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SherifOmran
        wrote on last edited by SherifOmran
        #4

        I pasted the config log file here
        https://pastebin.com/mNPmbGAz

        when i tried to compile an empty file, i get this
        mingw32-make[1]: *** No rule to make target 'C:/Qt/Qt-5.12.4/lib/libQt5Widgets.a', needed by 'release/ssl.exe'. Stop

        knowing that open ssl was compiled using vs 2017 nmake. I had to compile it as lib and then as static. the parameter i gave in -i and -l was the path to the static library.
        should i start from the beginning?

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

          What version of OpenSSL are you trying to use ?

          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
          • S Offline
            S Offline
            SherifOmran
            wrote on last edited by
            #6

            1.1.1 and current master

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SherifOmran
              wrote on last edited by SherifOmran
              #7

              i started over again and downloaded qt 5.13.0.
              I can compile it with

              ..\configure.bat -static -platform win32-g++ -release -prefix "c:\Qt\qt5.13.0_static" -opengl desktop -plugin-sql-sqlite -sql-sqlite -strip
              

              but i want to add openssl support. how should i do it? QT 5.13.0 online installer had a check box to download openssl and it downloaded a library in C:\QT\qt5.13.0\Tools\OpenSSL\Win_x86\lib
              should i use this library?
              what should i add to the command line?

              what is the equivalent to these libraries in windows
              SET OPENSSL_LIBS="/usr/${_arch}/lib/libssl.a /usr/${_arch}/lib/libcrypto.a -lws2_32 -lgdi32 -lcrypt32 -ldnsapi -liphlpapi"

              mrjjM 1 Reply Last reply
              0
              • S SherifOmran

                i started over again and downloaded qt 5.13.0.
                I can compile it with

                ..\configure.bat -static -platform win32-g++ -release -prefix "c:\Qt\qt5.13.0_static" -opengl desktop -plugin-sql-sqlite -sql-sqlite -strip
                

                but i want to add openssl support. how should i do it? QT 5.13.0 online installer had a check box to download openssl and it downloaded a library in C:\QT\qt5.13.0\Tools\OpenSSL\Win_x86\lib
                should i use this library?
                what should i add to the command line?

                what is the equivalent to these libraries in windows
                SET OPENSSL_LIBS="/usr/${_arch}/lib/libssl.a /usr/${_arch}/lib/libcrypto.a -lws2_32 -lgdi32 -lcrypt32 -ldnsapi -liphlpapi"

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @SherifOmran
                hi
                https://stackoverflow.com/questions/20843180/is-there-any-way-to-building-static-qt-with-static-openssl

                i think you also need
                -openssl-linked

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SherifOmran
                  wrote on last edited by
                  #9

                  i tried the following

                  ..\configure.bat -static -platform win32-g++ -release -prefix "c:\Qt\qt5.13.0_static" -opengl desktop -plugin-sql-sqlite -sql-sqlite -strip  -openssl-linked -I "C:\QT\qt5.13.0\Tools\OpenSSL\src\include" -L "C:\QT\qt5.13.0\Tools\OpenSSL\Win_x86\lib" OPENSSL_LIBS="-libcrypto -libssl"
                  

                  and

                  ..\configure.bat -static -platform win32-g++ -release -prefix "c:\Qt\qt5.13.0_static" -opengl desktop -plugin-sql-sqlite -sql-sqlite -strip  -openssl-linked -I "C:\QT\qt5.13.0\Tools\OpenSSL\src\include" OPENSSL_LIBS="C:\QT\qt5.13.0\Tools\OpenSSL\Win_x86\lib\libcrypto C:\QT\qt5.13.0\Tools\OpenSSL\Win_x86\lib\libssl"
                  

                  but they both fail
                  The sql library included here is the one downloaded from the qt online installer 1.1.1 b

                  I also tried with static libraries produced from compiling ssl as dll for release and then with no-shared (static) but also failed at config

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

                    One thing I'm not sure but don't you have an option to tell which version of OpenSSL you are using ?

                    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
                    • S Offline
                      S Offline
                      SherifOmran
                      wrote on last edited by SherifOmran
                      #11

                      i don't have this option. The packaged version of openssl from QT Installer is 1.1.1b and gets installed under Qt\tools path. The version i was trying to install is 1.1.1c and the master branch after being compiled.

                      The build works without openssl linked and without the I and I parameters and OPENSSL_LIBS parameter.
                      I am getting puzzled. The simple question is what is -I and -L parameters and were is Qt expecting to find the header files and which libraries should i link against?

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

                        Are you trying to build a 32 or 64 bit version of Qt ? If the later, you are using the wrong architecture for 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
                        1
                        • S Offline
                          S Offline
                          SherifOmran
                          wrote on last edited by SherifOmran
                          #13

                          ooops, this could be. how can i tell make to compile the 32 bit version of qt?
                          i used this -platform win32-g++
                          how can we make sure that openssl is 32 bits and not 64?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SherifOmran
                            wrote on last edited by
                            #14

                            i compiled openssl as follows

                            perl configure VC-WIN64A --release --prefix=T:\openssl\dll\x64\release -openssldir=T:\openssl\ssl
                            nmake
                            nmake test
                            nmake install_sw //this will copy to the dll folder and to program files/openssl/include / headers
                            nmake clean
                            
                            
                            perl configure VC-WIN64A --debug --prefix=T:\openssl\dll\x64\debug -openssldir=T:\openssl\ssl
                            nmake
                            nmake install_sw
                            nmake clean
                            
                            //release static
                            perl configure VC-WIN64A no-shared --release --prefix=T:\openssl\lib\x64\release -openssldir=T:\openssl\ssl
                            nmake
                            nmake install_sw
                            nmake clean
                            
                            
                            perl configure VC-WIN64A no-shared --debug --prefix=T:\openssl\lib\x64\debug -openssldir=T:\openssl\ssl
                            nmake
                            nmake install_sw
                            nmake clean
                            
                            

                            and compile Qt with nmake using visual studio 2019

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

                              How are you compiling Qt ?
                              What setup do you do in the terminal you use for the build ?

                              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
                              • S Offline
                                S Offline
                                SherifOmran
                                wrote on last edited by SherifOmran
                                #16

                                I downloaded Openssl 32 from the following link
                                and compiled qt with the following configure

                                set OPENSSL_HOME=C:\OpenSSL-Win32
                                
                                ..\configure -static -debug-and-release -platform win32-msvc2019 -static-runtime -ssl -openssl -openssl-linked -I %OPENSSL_HOME%\include -L %OPENSSL_HOME%\lib -opensource -confirm-license -opengl desktop -release -sql-sqlite -strip -qt-zlib -static-runtime -plugin-sql-sqlite -sql-sqlite -make tools -make libs -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -optimize-size -no-feature-d3d12
                                

                                Notice that i did not use OPENSSL_LIBS because it keeps failing. I tried OPENSSL_LIBS="-LC:\OpenSSL-Win32\lib -lssl -lcrypto" but it failed. May be i am making it wrong !
                                I used Qt 5.13. The content of my make file and the contents of my config log is here

                                now i created a simple qml application with hello label. When i run the application i get "can not find libssl-1_1.dll, same for crypto-1_1.dll". This means it is linked dynamically. When i copy those files beside the binary it works, but i want to link it statically.

                                I tried many combinations. I am compiling with vs 2019 compiler ? does it make a difference if i compile the application with MinGW although Qt is compiled with nmake?

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

                                  You either have to copy the dlls in the same folder as your application or modify the PATH environment in the Run part of the Project panel of Qt Creator and add the folder where they are.

                                  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
                                  1
                                  • S Offline
                                    S Offline
                                    SherifOmran
                                    wrote on last edited by
                                    #18

                                    but i don't want to deliver these files to the user? my try was to create a simple file that can be delivered to the user and that i uses TLS

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

                                      Then you have to also build OpenSSL statically.

                                      If you want to have a 100% fully static application, you have to build all your libraries and their dependencies as static. Note that this is nothing Qt specific.

                                      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
                                      1
                                      • S Offline
                                        S Offline
                                        SherifOmran
                                        wrote on last edited by
                                        #20

                                        As far as i understand, the file i downloaded from this link has a folder called lib inside it there is static where libcrypto.lib and libssl.lib and ossl_static.pdb exist. There is also another folder called engines-3.

                                        Assume that these libraries are statically built. how can we link it to qt to compile it using these libraries.
                                        This command failed

                                        OPENSSL_LIBS="-LC:\OpenSSL-Win32\lib -lssl -lcrypto"
                                        

                                        please download the file to see its content.
                                        could you please correct it?

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SherifOmran
                                          wrote on last edited by SherifOmran
                                          #21

                                          Here is a solution and feedback to the people searching in future for same issue using openssl 1.1.1+ and at

                                          guys the problem is as follows:
                                          1- to compile it as static, you must use -openssl-linked parameter
                                          2- but we think normally because we use the following parameters config will find the libraries.
                                          -I %OPENSSL_HOME%\include -L %OPENSSL_HOME%\lib
                                          but although these parameters are configured but config does not find the libraries and prints out the following error. It seems that these parameters are necessary only to find the header files and not to find the libraries

                                          None of [libssl.dll.a libssl.a ssl.dll.a ssl.a ssl.lib] found in [] and global paths.
                                          None of [libcrypto.dll.a libcrypto.a crypto.dll.a crypto.a crypto.lib] found in [] and global paths.
                                          

                                          The solution to this is to add the path of these static libraries and openssl binary into your global PATH variable, this way it will find the .a libraries. I used Openssl 1.1.1

                                          do the following for a quick test
                                          where libssl.a
                                          where openssl

                                          if you get an output, so you can be sure it will work.

                                          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