Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Fail to link to OpenSSL for Anroid
Forum Updated to NodeBB v4.3 + New Features

Fail to link to OpenSSL for Anroid

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 288 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.
  • M Offline
    M Offline
    mjs225
    wrote on last edited by mjs225
    #1

    I want to use https for a Qt Quick Andoird project in Qt6.2.3. I followed instructions in https://doc.qt.io/qt-6/android-openssl-support.html but still failed to link OpenSSL.

    Here's what I did:

    1. git clone https://github.com/KDAB/android_openssl.git
    2. Create new QtQuick project targeting Android arm64-v8a
    3. In CMakeLists.txt, include() the openssl project‘s CMakeLists.txt, add Qt6::Network dependency.
    4. Write code to print the result of QSslSocket::supportsSsl()

    I've also tried to link to the static library, but QSslSocket::supportsSsl() still returns false.
    Link to libcrypto_1_1.so and libssl_1_1.so in android_openssl/latest/arm64/ lead to program crash on start up.

    How can I link to OpenSSL? Thanks!

    My CMakeLists.txt:

    cmake_minimum_required(VERSION 3.16)
    
    project(testAndroidOpenSSL VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.2 COMPONENTS Quick Network REQUIRED)
    
    if (ANDROID)
        include(D:/SrcProgram/android_openssl/CMakeLists.txt)
    endif()
    
    qt_add_executable(apptestAndroidOpenSSL
        main.cpp
    )
    
    qt_add_qml_module(apptestAndroidOpenSSL
        URI testAndroidOpenSSL
        VERSION 1.0
        QML_FILES main.qml 
    )
    
    set_target_properties(apptestAndroidOpenSSL PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_compile_definitions(apptestAndroidOpenSSL
        PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(apptestAndroidOpenSSL
        PRIVATE Qt6::Quick Qt6::Network)
    
    
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mjs225
      wrote on last edited by
      #2

      Problem solved.
      I find that although ANDROID_EXTRA_LIBS is set in the CMakeLists, libcrypto_1_1.so and libcrypto_1_1.so are not copied into the 'libs/arm64' directory of the Android build directory.
      Maybe something got wrong in the build system. After I copy the two shared libraries and rebuild, they can be properly packed and loaded now.

      1 Reply Last reply
      1

      • Login

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