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. Problem with include openssl on Qt Andrioid
Qt 6.11 is out! See what's new in the release blog

Problem with include openssl on Qt Andrioid

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 5 Posters 3.3k 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.
  • KroMignonK KroMignon

    @Creatorczyk said in Problem with include openssl on Qt Andrioid:

    Could this be a problem with my Qt 5.15.2?

    Not really. the pri file only includes the library to the project. It do not add any header file in INCLUDEPATH or DEPENDPATH
    Why do you include openssl headers in you C++ file?

    C Offline
    C Offline
    Creatorczyk
    wrote on last edited by
    #7

    @KroMignon Because I want to use functions from lib to encode RSA.

    I added:

    INCLUDEPATH += /home/john/openssl_test/static/include/
    

    The bug with headers has resolved, but although intelisense can see functions, the application still does not build

    ec027265-3393-4ada-b385-8286d85b64d6-image.png

    KroMignonK 1 Reply Last reply
    0
    • C Creatorczyk

      @KroMignon Because I want to use functions from lib to encode RSA.

      I added:

      INCLUDEPATH += /home/john/openssl_test/static/include/
      

      The bug with headers has resolved, but although intelisense can see functions, the application still does not build

      ec027265-3393-4ada-b385-8286d85b64d6-image.png

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #8

      @Creatorczyk said in Problem with include openssl on Qt Andrioid:

      The bug with headers has resolved, but although intelisense can see functions, the application still does not build

      Because you also need to say that you are using the libs ;)
      Add this in your PRO file:

      LIBS += -llibcrypto -llibssl
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      C 1 Reply Last reply
      0
      • KroMignonK KroMignon

        @Creatorczyk said in Problem with include openssl on Qt Andrioid:

        The bug with headers has resolved, but although intelisense can see functions, the application still does not build

        Because you also need to say that you are using the libs ;)
        Add this in your PRO file:

        LIBS += -llibcrypto -llibssl
        
        C Offline
        C Offline
        Creatorczyk
        wrote on last edited by
        #9

        @KroMignon It did not help :(

        140589a6-6460-43a1-b1f4-b2596c8f7405-image.png

        KroMignonK 1 Reply Last reply
        0
        • C Creatorczyk

          @KroMignon It did not help :(

          140589a6-6460-43a1-b1f4-b2596c8f7405-image.png

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by
          #10

          @Creatorczyk said in Problem with include openssl on Qt Andrioid:

          It did not help :(

          It seems that you have to specify the location of the libs to avoid error error: cannot find XXX
          According to your posts, you are using Qt 5.15 for Android, so I would suggest to do it as follow:

          CONFIG(release, debug|release): SSL_PATH = /home/john/openssl_test
          else: SSL_PATH = /home/john/openssl_test/no-asm
          
          contains(ANDROID_TARGET_ARCH, armeabi-v7a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm
          contains(ANDROID_TARGET_ARCH, arm64-v8a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm64
          contains(ANDROID_TARGET_ARCH, x86): SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86
          contains(ANDROID_TARGET_ARCH, x86_64) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86_64
          
          LIBS += -L$$SSL_PATH -llibcrypto
          LIBS += -L$$SSL_PATH -llibssl
          

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          jsulmJ 1 Reply Last reply
          0
          • KroMignonK KroMignon

            @Creatorczyk said in Problem with include openssl on Qt Andrioid:

            It did not help :(

            It seems that you have to specify the location of the libs to avoid error error: cannot find XXX
            According to your posts, you are using Qt 5.15 for Android, so I would suggest to do it as follow:

            CONFIG(release, debug|release): SSL_PATH = /home/john/openssl_test
            else: SSL_PATH = /home/john/openssl_test/no-asm
            
            contains(ANDROID_TARGET_ARCH, armeabi-v7a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm
            contains(ANDROID_TARGET_ARCH, arm64-v8a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm64
            contains(ANDROID_TARGET_ARCH, x86): SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86
            contains(ANDROID_TARGET_ARCH, x86_64) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86_64
            
            LIBS += -L$$SSL_PATH -llibcrypto
            LIBS += -L$$SSL_PATH -llibssl
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #11

            @KroMignon said in Problem with include openssl on Qt Andrioid:

            LIBS += -L$$SSL_PATH -llibcrypto
            LIBS += -L$$SSL_PATH -llibssl

            It should be

            LIBS += -L$$SSL_PATH -lcrypto
            LIBS += -L$$SSL_PATH -lssl
            

            (without lib prefix).
            @Creatorczyk

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            KroMignonK 1 Reply Last reply
            1
            • jsulmJ jsulm

              @KroMignon said in Problem with include openssl on Qt Andrioid:

              LIBS += -L$$SSL_PATH -llibcrypto
              LIBS += -L$$SSL_PATH -llibssl

              It should be

              LIBS += -L$$SSL_PATH -lcrypto
              LIBS += -L$$SSL_PATH -lssl
              

              (without lib prefix).
              @Creatorczyk

              KroMignonK Offline
              KroMignonK Offline
              KroMignon
              wrote on last edited by
              #12

              @jsulm said in Problem with include openssl on Qt Andrioid:

              It should be
              LIBS += -L$$SSL_PATH -lcrypto
              LIBS += -L$$SSL_PATH -lssl

              (without lib prefix).

              Thanks :)

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              C 1 Reply Last reply
              0
              • KroMignonK KroMignon

                @jsulm said in Problem with include openssl on Qt Andrioid:

                It should be
                LIBS += -L$$SSL_PATH -lcrypto
                LIBS += -L$$SSL_PATH -lssl

                (without lib prefix).

                Thanks :)

                C Offline
                C Offline
                Creatorczyk
                wrote on last edited by
                #13

                @KroMignon @jsulm I was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:

                30d838d8-112b-4326-9368-60e89dbf8c80-image.png

                KroMignonK 1 Reply Last reply
                0
                • C Creatorczyk

                  @KroMignon @jsulm I was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:

                  30d838d8-112b-4326-9368-60e89dbf8c80-image.png

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #14

                  @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                  was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:

                  This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with include(c:/Android/android-sdk/android_openssl/openssl.pri).

                  As APK file is a ZIP archive, you could verify the openSSL libs are include.

                  You could also try to add them by adding following code in your PRO file:

                  ANDROID_EXTRA_LIBS += \
                       $SSL_PATH/libcrypto.so \
                       $SSL_PATH/libssl.so
                  

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  C 2 Replies Last reply
                  1
                  • KroMignonK KroMignon

                    @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                    was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:

                    This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with include(c:/Android/android-sdk/android_openssl/openssl.pri).

                    As APK file is a ZIP archive, you could verify the openSSL libs are include.

                    You could also try to add them by adding following code in your PRO file:

                    ANDROID_EXTRA_LIBS += \
                         $SSL_PATH/libcrypto.so \
                         $SSL_PATH/libssl.so
                    
                    C Offline
                    C Offline
                    Creatorczyk
                    wrote on last edited by
                    #15

                    @KroMignon said in Problem with include openssl on Qt Andrioid:

                    ANDROID_EXTRA_LIBS +=
                    $SSL_PATH/libcrypto.so
                    $SSL_PATH/libssl.so

                    I changed to

                    ANDROID_EXTRA_LIBS += \
                         $$SSL_PATH/libcrypto.so \
                         $$SSL_PATH/libssl.so
                    

                    And it works. Thanks!!

                    1 Reply Last reply
                    0
                    • KroMignonK KroMignon

                      @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                      was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:

                      This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with include(c:/Android/android-sdk/android_openssl/openssl.pri).

                      As APK file is a ZIP archive, you could verify the openSSL libs are include.

                      You could also try to add them by adding following code in your PRO file:

                      ANDROID_EXTRA_LIBS += \
                           $SSL_PATH/libcrypto.so \
                           $SSL_PATH/libssl.so
                      
                      C Offline
                      C Offline
                      Creatorczyk
                      wrote on last edited by Creatorczyk
                      #16

                      @KroMignon Hi, unfortunately I still have a problem. I've changed repository locations and want to run the project. Building is successful, but again there was a problem running the application on the phone:

                      My pro file:
                      703c40eb-c03a-471c-91f7-c0381f0e1de4-image.png

                      Application output:
                      43b54461-7326-4f06-ace3-576e176556ca-image.png

                      It is the same error as before, despite the added:
                      0f39f55a-3a26-429a-8590-377901a05ac5-image.png

                      The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?

                      KroMignonK 1 Reply Last reply
                      0
                      • C Creatorczyk

                        @KroMignon Hi, unfortunately I still have a problem. I've changed repository locations and want to run the project. Building is successful, but again there was a problem running the application on the phone:

                        My pro file:
                        703c40eb-c03a-471c-91f7-c0381f0e1de4-image.png

                        Application output:
                        43b54461-7326-4f06-ace3-576e176556ca-image.png

                        It is the same error as before, despite the added:
                        0f39f55a-3a26-429a-8590-377901a05ac5-image.png

                        The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?

                        KroMignonK Offline
                        KroMignonK Offline
                        KroMignon
                        wrote on last edited by KroMignon
                        #17

                        @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                        The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?

                        The error you have is clear, the library libcrypto.so is not part of your APK, and cannot be found at application start.
                        Are you sure SSL_PATH is what it should be?
                        you could add message(SSL_PATH is $$SSL_PATH) to show what you have configured.

                        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                        C 1 Reply Last reply
                        0
                        • KroMignonK KroMignon

                          @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                          The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?

                          The error you have is clear, the library libcrypto.so is not part of your APK, and cannot be found at application start.
                          Are you sure SSL_PATH is what it should be?
                          you could add message(SSL_PATH is $$SSL_PATH) to show what you have configured.

                          C Offline
                          C Offline
                          Creatorczyk
                          wrote on last edited by
                          #18

                          @KroMignon I resolved problem by check checkboxes in Build Steps with archictures. Thanks

                          1 Reply Last reply
                          0
                          • KroMignonK KroMignon

                            @Creatorczyk said in Problem with include openssl on Qt Andrioid:

                            I use Qt 5.15.2, maybe it's couse of problem

                            AFAIK, you have to install open ssl libs with help Qt Creator.
                            In Tools / Options select Devices and go to tab Android
                            There you will find a button called "Download OpenSSL"
                            f6e14480-17d4-4e45-98da-a5f70b05a637-image.png

                            [EDIT]: After that you have to include the libs in your PRO / CMakeLists.txt file as explained here: https://doc.qt.io/qt-5/android-openssl-support.html#using-openssl-libraries-with-qt-for-android

                            In my case it would be

                            • for qmake:
                            android: include(c:/Android/android-sdk/android_openssl/openssl.pri)
                            
                            • for cmake:
                            if (ANDROID)
                                include(c:/Android/android-sdk/android_openssl/CMakeLists.txt)
                            endif()
                            
                            8Observer88 Offline
                            8Observer88 Offline
                            8Observer8
                            wrote on last edited by 8Observer8
                            #19

                            @KroMignon said in Problem with include openssl on Qt Andrioid:

                            for qmake

                            Thank you very much!

                            63fc71f4-e8f5-4dde-a1e3-a7d25fcd37a9-image.png

                            QT += core gui websockets widgets
                            
                            android: include(C:/Qt/Tools/OpenSSL-1.1.1j/Win_x64/bin/openssl.pri)
                            
                            CONFIG += c++17
                            
                            SOURCES += \
                                main.cpp
                            

                            I have deployed a simple server example with Box2D-WASM in JavaScript on free Glitch hosting: https://glitch.com/edit/#!/merciful-regal-soursop from the GitHub repository: send-gravity-from-server-to-client-box2d-wasm-js This example sends the gravity value in JSON format when a client is connected. The following example is a client that works on Android, Desktop, and Web (with Qt WebAssembly). It is useful example to make multiplayer games with physics on the server side:

                            Output:

                            connected
                            "{\"action\":\"scGravity\",\"data\":\"{\\\"x\\\":0,\\\"y\\\":-3}\"}"
                            

                            main.cpp

                            #include <QtNetwork/QNetworkRequest>
                            #include <QtWebSockets/QWebSocket>
                            #include <QtWidgets/QApplication>
                            #include <QtWidgets/QWidget>
                            
                            class Widget : public QWidget
                            {
                                Q_OBJECT
                            
                            public:
                            
                                Widget()
                                {
                                    setWindowTitle("Show gravity from server with Box2D-WASM");
                                    resize(420, 200);
                            
                                    connect(&m_webSocket, &QWebSocket::connected,
                                        this, &Widget::onConnected);
                                    connect(&m_webSocket, &QWebSocket::textMessageReceived,
                                        this, &Widget::onMessageReceived);
                                    connect(&m_webSocket, &QWebSocket::errorOccurred,
                                        this, &Widget::onErrorOccurred);
                            
                                    QUrl url("wss://merciful-regal-soursop.glitch.me");
                            
                                    QNetworkRequest request;
                                    request.setUrl(url);
                                    request.setRawHeader(QByteArray("User-Agent"), QByteArray("Mozilla/5.0 "
                                        "(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
                                        "Chrome/124.0.0.0 Safari/537.36"));
                            
                                    m_webSocket.open(request);
                                }
                                ~Widget() {}
                            
                            private slots:
                            
                                void onConnected()
                                {
                                    qDebug() << "connected";
                                }
                                void onMessageReceived(const QString &message)
                                {
                                    qDebug() << message;
                                }
                            
                                void onErrorOccurred(QAbstractSocket::SocketError error)
                                {
                                    qDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
                                    qDebug() << "Error:" << error;
                                    qDebug() << "Device supports OpenSSL:" << QSslSocket::supportsSsl();
                                    qDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
                                }
                            
                            private:
                            
                                QWebSocket m_webSocket;
                            };
                            
                            #include "main.moc"
                            
                            int main(int argc, char *argv[])
                            {
                                QApplication a(argc, argv);
                                Widget w;
                                w.show();
                                return a.exec();
                            }
                            
                            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