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 19 Jun 2019, 23:06 last edited by
    #1

    I am trying to compile qt static with open ssl and used qt 5.12.4 but the compile failed with error feature 'openssl-linked' was enabled, but the precondition '!features.securertransport && libs.openssl' failed.

    I followed the following tutorial to compile open ssl with vs2017
    link text

    I tried to compile using

    configure -static -opensource -nomake examples -opengl desktop -openssl  -openssl-linked -I T:\openssl\dll\x64\release\include -L T:\openssl\dll\x64\release\lib OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32"
    

    I attached config.log for details.

    [0_1560985564414_config.log](Uploading 100%)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Jun 2019, 21:33 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 21 Jun 2019, 18:33 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 21 Jun 2019, 18:35 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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 21 Jun 2019, 21:36 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 22 Jun 2019, 01:10 last edited by
              #6

              1.1.1 and current master

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SherifOmran
                wrote on 22 Jun 2019, 10:09 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"

                M 1 Reply Last reply 22 Jun 2019, 10:19
                0
                • S SherifOmran
                  22 Jun 2019, 10:09

                  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"

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 22 Jun 2019, 10:19 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 22 Jun 2019, 10:54 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
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 22 Jun 2019, 17:39 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 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

                                          1/22

                                          19 Jun 2019, 23:06

                                          • Login

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