Skip to content
  • Kategorien
  • Aktuell
  • Tags
  • Beliebt
  • Benutzer
  • Gruppen
  • Suche
  • Get Qt Extensions
  • Ungelöst
Einklappen
Markenlogo
  1. Übersicht
  2. General talk
  3. Qt 6
  4. Qt6 Static Cross Compile with OpenSSL
Forum Updated to NodeBB v4.3 + New Features

Qt6 Static Cross Compile with OpenSSL

Geplant Angeheftet Gesperrt Verschoben Gelöst Qt 6
18 Beiträge 3 Kommentatoren 4.4k Aufrufe 1 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • S Offline
    S Offline
    squinky86
    schrieb am zuletzt editiert von
    #1

    I am unable to get Qt6 (6.3.0 rc) to cross compile with OpenSSL statically.

    Prerequisites: Ubuntu 21.10 (Impish)
    PPA: https://launchpad.net/~rncbc/+archive/ubuntu/qt6.3-static-impish
    Cross-Compiler: "apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64"

    Use POSIX threads: "update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix && update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix"

    Build OpenSSL 1.1.1n (in /home/me/openssl-1.1.1n): "./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make"

    Attempt to configure Qt 6.3.0 RC: "./configure -platform linux-g++-64 -qt-host-path /opt/qt6.3-static -xplatform win32-g++ -device-option CROSS_COMPILE=x86_64-w64-mingw32- -release -opengl desktop -mp -static -static-runtime -no-shared -nomake examples -no-icu -optimize-size -openssl-linked -- -DOPENSSL_ROOT_DIR=/home/me/openssl-1.1.1n"

    results in:

    ERROR: Feature "openssl": Forcing to "ON" breaks its condition:
        QT_FEATURE_openssl_runtime OR QT_FEATURE_openssl_linked
    Condition values dump:
        QT_FEATURE_openssl_runtime = "OFF"
        QT_FEATURE_openssl_linked = "OFF"
    

    Note: I get the same results trying to also pass mixtures of the following options:
    OPENSSL_LIBS=" -L/home/me/openssl-1.1.1n -llibssl -llibcrypto -luser32 -lcrypt32 -lws2_32 -lgdi32"
    OPENSSL_CRYPTO_LIBRARY="/home/me/openssl-1.1.1n"
    -I/home/me/openssl-1.1.1n/include

    Does anyone have a walkthrough of static OpenSSL cross compiling? Would someone be willing to reproduce the environment I have above and tell me what I'm doing wrong?

    1 Antwort Letzte Antwort
    0
    • S Offline
      S Offline
      squinky86
      schrieb am zuletzt editiert von squinky86
      #9

      I filed a QTBUG and @Croitor-Alexandru patiently pointed me towards needing to specify the cmake profile as well when configuring a cross compile. Qt6 configured correctly (though it's still not building) with his input.

      Missing option: "-DCMAKE_TOOLCHAIN_FILE=/home/jon/w64/profile.cmake" where profile.cmake is the same one I use for everything. Just in case anyone comes here from google, here's the profile that mostly worked (you can probably drop the Fortran compiler, but I at least know this works and don't feel like testing without it).

      set(CMAKE_SYSTEM_NAME Windows)
      set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
      set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
      set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
      set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
      set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
      set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
      set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
      set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
      set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
      

      That gets through the configure, but the build fails pretty hard in the Gui target. I'm going to try some things (update cmake, switch to ninja, etc.) and create another thread in these forums if I can't figure it out on my end.

      EDIT: Got it working with no additional modifications using cmake 3.18 and regular Makefiles.

      1 Antwort Letzte Antwort
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        schrieb am zuletzt editiert von
        #2

        Hi,

        Might be a silly question but are you sure your OpenSSL build is 64 bit ?

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

        1 Antwort Letzte Antwort
        0
        • S Offline
          S Offline
          squinky86
          schrieb am zuletzt editiert von
          #3

          @SGaist said in Qt6 Static Cross Compile with OpenSSL:

          Hi,

          Might be a silly question but are you sure your OpenSSL build is 64 bit ?

          Confirmed.

          $ objdump -f libcrypto.a
          In archive libcrypto.a:
          
          aes_cbc.o:     file format pe-x86-64
          architecture: i386:x86-64, flags 0x00000039:
          HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
          start address 0x0000000000000000
          ...
          
          1 Antwort Letzte Antwort
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            schrieb am zuletzt editiert von
            #4

            Did you check the configure log files to see exactly what failed in the OpenSSL tests ?

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

            S 1 Antwort Letzte Antwort
            0
            • SGaistS SGaist

              Did you check the configure log files to see exactly what failed in the OpenSSL tests ?

              S Offline
              S Offline
              squinky86
              schrieb am zuletzt editiert von squinky86
              #5

              @SGaist said in Qt6 Static Cross Compile with OpenSSL:

              Did you check the configure log files to see exactly what failed in the OpenSSL tests ?

              I've been slowly tracking this down more and more thanks to the error logs. It appears that the OpenSSL check uses the platform's C++ compiler rather than the cross compiler I'm configuring Qt to use. This appears, to me, to be a bug - when the cross compile device option is selected, the OpenSSL linking check should use the cross compiler.

              Pease note that I had to set up a VM on another computer, so the directory structure has moved from /home/me to /home/jon/w64 for openssl and Qt 6.3.0 RC. I've also been trying this with OpenSSL 1.1.1n and OpenSSL 3.0.2 with the same results.

              Performing C++ SOURCE FILE Test HAVE_openssl failed with the following output:
              Change Dir: /home/jon/w64/qtbase-everywhere-src-6.3.0-rc/CMakeFiles/CMakeTmp
              
              Run Build Command(s):/usr/bin/gmake cmTC_30003/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_30003.dir/build.make CMakeFiles/cmTC_30003.dir/build
              gmake[1]: Entering directory '/home/jon/w64/qtbase-everywhere-src-6.3.0-rc/CMakeFiles/CMakeTmp'
              Building CXX object CMakeFiles/cmTC_30003.dir/src.cxx.o
              /usr/bin/c++  -isystem /home/jon/w64/openssl-3.0.2/include -DHAVE_openssl -fPIE -std=gnu++17 -o CMakeFiles/cmTC_30003.dir/src.cxx.o -c /home/jon/w64/qtbase-everywhere-src-6.3.0-rc/CMakeFiles/CMakeTmp/src.cxx
              Linking CXX executable cmTC_30003
              /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_30003.dir/link.txt --verbose=1
              /usr/bin/c++  -DHAVE_openssl CMakeFiles/cmTC_30003.dir/src.cxx.o -o cmTC_30003  /home/jon/w64/openssl-3.0.2/libssl.a /home/jon/w64/openssl-3.0.2/libcrypto.a -ldl
              /usr/bin/ld: /home/jon/w64/openssl-3.0.2/libssl.a(libssl-lib-ssl_lib.obj):ssl_lib.c:(.text+0x650): undefined reference to `__mingw_vsprintf'
              /usr/bin/ld: /home/jon/w64/openssl-3.0.2/libssl.a(libssl-lib-ssl_lib.obj):ssl_lib.c:(.text+0x6bdc): undefined reference to `__imp__time64'
              /usr/bin/ld: /home/jon/w64/openssl-3.0.2/libssl.a(libssl-lib-ssl_sess.obj):ssl_sess.c:(.text+0x857): undefined reference to `__imp__time64'
              /usr/bin/ld: /home/jon/w64/openssl-3.0.2/libssl.a(libssl-lib-ssl_sess.obj):ssl_sess.c:(.text+0x1497): undefined reference to `__imp__time64'
              /usr/bin/ld: /home/jon/w64/openssl-3.0.2/libssl.a(libssl-lib-ssl_sess.obj):ssl_sess.c:(.text+0x1a8a): undefined reference to `__imp__time64'
              ...
              

              Now that I understand what's going wrong, I'm struggling trying to figure out how to get the Qt configure system to pass the mingw cross compiler to this check rather than /usr/bin/c++.

              1 Antwort Letzte Antwort
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                schrieb am zuletzt editiert von
                #6

                Sounds fishy indeed.

                Can you share the configuration line you use ?

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

                S 1 Antwort Letzte Antwort
                0
                • SGaistS SGaist

                  Sounds fishy indeed.

                  Can you share the configuration line you use ?

                  S Offline
                  S Offline
                  squinky86
                  schrieb am zuletzt editiert von
                  #7

                  @SGaist said in Qt6 Static Cross Compile with OpenSSL:

                  Sounds fishy indeed.

                  Can you share the configuration line you use ?

                  They are in the original post.

                  OpenSSL configure: ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32-

                  Qt 6.3.0 configure (note, this time I'm using an unsupported cmake, but the error was the same with an upgraded cmake installed with snap or if I use openssl-1.1.1n): ./configure -platform linux-g++-64 -qt-host-path /opt/qt6.3-static -xplatform win32-g++ -device-option CROSS_COMPILE=x86_64-w64-mingw32- -release -opengl desktop -mp -static -static-runtime -no-shared -nomake examples -no-icu -optimize-size -openssl-linked -- -DQT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT=3.18 -DOPENSSL_ROOT_DIR=/home/jon/w64/openssl-3.0.2

                  1 Antwort Letzte Antwort
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    schrieb am zuletzt editiert von
                    #8

                    Nothing stands out as wrong with the options you use.

                    You may have found an issue with the win32 cross-compilation.

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

                    rightecR 1 Antwort Letzte Antwort
                    0
                    • S Offline
                      S Offline
                      squinky86
                      schrieb am zuletzt editiert von squinky86
                      #9

                      I filed a QTBUG and @Croitor-Alexandru patiently pointed me towards needing to specify the cmake profile as well when configuring a cross compile. Qt6 configured correctly (though it's still not building) with his input.

                      Missing option: "-DCMAKE_TOOLCHAIN_FILE=/home/jon/w64/profile.cmake" where profile.cmake is the same one I use for everything. Just in case anyone comes here from google, here's the profile that mostly worked (you can probably drop the Fortran compiler, but I at least know this works and don't feel like testing without it).

                      set(CMAKE_SYSTEM_NAME Windows)
                      set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
                      set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
                      set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
                      set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
                      set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
                      set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
                      set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
                      set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
                      set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
                      

                      That gets through the configure, but the build fails pretty hard in the Gui target. I'm going to try some things (update cmake, switch to ninja, etc.) and create another thread in these forums if I can't figure it out on my end.

                      EDIT: Got it working with no additional modifications using cmake 3.18 and regular Makefiles.

                      1 Antwort Letzte Antwort
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        schrieb am zuletzt editiert von
                        #10

                        Thanks for the detailed feedback !

                        Can you share the bug url ? That may be useful for other people.

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

                        S 1 Antwort Letzte Antwort
                        0
                        • SGaistS SGaist

                          Thanks for the detailed feedback !

                          Can you share the bug url ? That may be useful for other people.

                          S Offline
                          S Offline
                          squinky86
                          schrieb am zuletzt editiert von squinky86
                          #11

                          @SGaist said in Qt6 Static Cross Compile with OpenSSL:

                          Thanks for the detailed feedback !

                          Can you share the bug url ? That may be useful for other people.

                          QTBUG-102250

                          I now have Qt6 cross compiled and working. Some of my slots and signals are not working, but I'm slowly figuring it out.

                          EDIT: Slots and signals are now fixed. Qt5 gave me some overloaded interfaces that I wasn't supposed to be using. Switching those over resulted in successful unit tests! Once I get appveyor set up for my nightly builds, I'll be 100% ported over to Qt6 thanks to everyone's help here.

                          1 Antwort Letzte Antwort
                          1
                          • SGaistS SGaist

                            Nothing stands out as wrong with the options you use.

                            You may have found an issue with the win32 cross-compilation.

                            rightecR Offline
                            rightecR Offline
                            rightec
                            schrieb am zuletzt editiert von
                            #12

                            @SGaist Hello
                            if it possible i would like some more explanation about the config command.
                            If i read " -openssl-linked --" I imagine that openSSL support is already been built against the cross compiler and
                            the result of building lays on the folder indicated by -DOPENSSL_ROOT_DIR=/home/jon/w64/openssl-3.0.2. (in this example)
                            But what about the native QT openSsl support that we have in "qtbase/src/plugins/tls/openssl" ?
                            How can we include it in the cross compilation?

                            My question rises from an error that i got compilig a websocket QT project against arm32:
                            error: ‘class QWebSocket’ has no member named ‘ignoreSslErrors’
                            96 | m_webSocket.ignoreSslErrors();

                            Thanks for answering
                            Regards
                            FM

                            SGaistS 1 Antwort Letzte Antwort
                            0
                            • rightecR rightec

                              @SGaist Hello
                              if it possible i would like some more explanation about the config command.
                              If i read " -openssl-linked --" I imagine that openSSL support is already been built against the cross compiler and
                              the result of building lays on the folder indicated by -DOPENSSL_ROOT_DIR=/home/jon/w64/openssl-3.0.2. (in this example)
                              But what about the native QT openSsl support that we have in "qtbase/src/plugins/tls/openssl" ?
                              How can we include it in the cross compilation?

                              My question rises from an error that i got compilig a websocket QT project against arm32:
                              error: ‘class QWebSocket’ has no member named ‘ignoreSslErrors’
                              96 | m_webSocket.ignoreSslErrors();

                              Thanks for answering
                              Regards
                              FM

                              SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              schrieb am zuletzt editiert von
                              #13

                              @rightec hi,

                              OpenSSL linked means that the backend is directly linked against OpenSSL. The plugins/tls/openssl folder is that backend.

                              If you have the support missing, then it means that the detection somehow failed. Check the cmake logs to see what exactly failed.

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

                              rightecR 1 Antwort Letzte Antwort
                              0
                              • SGaistS SGaist

                                @rightec hi,

                                OpenSSL linked means that the backend is directly linked against OpenSSL. The plugins/tls/openssl folder is that backend.

                                If you have the support missing, then it means that the detection somehow failed. Check the cmake logs to see what exactly failed.

                                rightecR Offline
                                rightecR Offline
                                rightec
                                schrieb am zuletzt editiert von
                                #14

                                @SGaist Hello
                                First of all, thank you for your clarification
                                I was able to compile correctly after downloading the openSSL source code from git (OpenSSL_1_1_1-stable branch) and building it against the cross compiler.
                                Building process seems ok now, but at run time the qt sample sslechoclient returns me the following:

                                ./sslechoclient.sh
                                qt.network.ssl: The backend "cert-only" does not support QSslKey
                                qt.network.ssl: Active TLS backend does not support key creation
                                qt.network.ssl: The backend "cert-only" does not support QSslKey
                                qt.network.ssl: Active TLS backend does not support key creation
                                qt.network.ssl: The backend "cert-only" does not support QSslKey
                                qt.network.ssl: Active TLS backend does not support key creation
                                qt.network.ssl: The backend "cert-only" does not support QSslKey
                                qt.network.ssl: Active TLS backend does not support key creation

                                That sounds me strange. The OpenSSL version i've cross-compiled is 1.1.1t, the version i got on my Ubuntu host system is 1.1.1f. That is the only difference.
                                Do you have any idea?

                                QT is 6.2.4 on both target and host
                                Thanks
                                Regards
                                FM

                                rightecR 1 Antwort Letzte Antwort
                                0
                                • rightecR rightec

                                  @SGaist Hello
                                  First of all, thank you for your clarification
                                  I was able to compile correctly after downloading the openSSL source code from git (OpenSSL_1_1_1-stable branch) and building it against the cross compiler.
                                  Building process seems ok now, but at run time the qt sample sslechoclient returns me the following:

                                  ./sslechoclient.sh
                                  qt.network.ssl: The backend "cert-only" does not support QSslKey
                                  qt.network.ssl: Active TLS backend does not support key creation
                                  qt.network.ssl: The backend "cert-only" does not support QSslKey
                                  qt.network.ssl: Active TLS backend does not support key creation
                                  qt.network.ssl: The backend "cert-only" does not support QSslKey
                                  qt.network.ssl: Active TLS backend does not support key creation
                                  qt.network.ssl: The backend "cert-only" does not support QSslKey
                                  qt.network.ssl: Active TLS backend does not support key creation

                                  That sounds me strange. The OpenSSL version i've cross-compiled is 1.1.1t, the version i got on my Ubuntu host system is 1.1.1f. That is the only difference.
                                  Do you have any idea?

                                  QT is 6.2.4 on both target and host
                                  Thanks
                                  Regards
                                  FM

                                  rightecR Offline
                                  rightecR Offline
                                  rightec
                                  schrieb am zuletzt editiert von
                                  #15

                                  @rightec said in Qt6 Static Cross Compile with OpenSSL:

                                  Active TLS backend does not support key creation

                                  I solved compiling openSSL 111f on the target

                                  SGaistS 1 Antwort Letzte Antwort
                                  0
                                  • rightecR rightec

                                    @rightec said in Qt6 Static Cross Compile with OpenSSL:

                                    Active TLS backend does not support key creation

                                    I solved compiling openSSL 111f on the target

                                    SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    schrieb am zuletzt editiert von
                                    #16

                                    @rightec any chances you built OpenSSL for your host rather than your target ?

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

                                    rightecR 1 Antwort Letzte Antwort
                                    0
                                    • SGaistS SGaist

                                      @rightec any chances you built OpenSSL for your host rather than your target ?

                                      rightecR Offline
                                      rightecR Offline
                                      rightec
                                      schrieb am zuletzt editiert von
                                      #17

                                      @SGaist I did not try. BTW host is 64 bit and target 32.

                                      SGaistS 1 Antwort Letzte Antwort
                                      0
                                      • rightecR rightec

                                        @SGaist I did not try. BTW host is 64 bit and target 32.

                                        SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        schrieb am zuletzt editiert von
                                        #18

                                        The fact that it's a 32 bit target is not an issue. Depending on the library, the harder is often to make its build system use the cross-compiler on the host (things have vastly improved on that side since I was doing embedded work).

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

                                        1 Antwort Letzte Antwort
                                        0
                                        • F FrogCruiser referenced this topic on

                                        • Anmelden

                                        • Anmelden oder registrieren, um zu suchen
                                        • Erster Beitrag
                                          Letzter Beitrag
                                        0
                                        • Kategorien
                                        • Aktuell
                                        • Tags
                                        • Beliebt
                                        • Benutzer
                                        • Gruppen
                                        • Suche
                                        • Get Qt Extensions
                                        • Ungelöst