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
QtWS25 Last Chance

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.
  • S Offline
    S Offline
    SherifOmran
    wrote on 22 Jun 2019, 18:25 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Jun 2019, 22:03 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 25 Jun 2019, 22:44 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 26 Jun 2019, 09:11 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 Jun 2019, 19:03 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 29 Jun 2019, 12:32 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 29 Jun 2019, 20:43 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 1 Jul 2019, 14:07 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
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 1 Jul 2019, 15:56 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 1 Jul 2019, 21:54 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 2 Jul 2019, 20:59 last edited by SherifOmran 7 Feb 2019, 21:59
                        #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
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 3 Jul 2019, 06:47 last edited by
                          #22

                          @SherifOmran said in how to compile qt static with open ssl:

                          PATH

                          If you really need to change that variable, then do it only in the terminal you use to build your stuff. It's never a good idea to add the path to such sensitive libraries system wide as you might break unrelated applications.

                          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

                          20/22

                          1 Jul 2019, 21:54

                          • Login

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