Unsolved QT6.3 Android couldn't link with OpenSSL libs
-
Despite having the correct setup in the cmake file as per the documentation. Upon loading the
App
fails to load the correct OpenSSL libs.CMake file :
if (ANDROID) # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Android") include(${ANDROID_SDK_ROOT}/android_openssl/CMakeLists.txt) endif(ANDROID) # .... qt_add_executable(App ${SHARED_SOURCES} ${APP_SOURCES})
Error messages upon the App start :
E linker : library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/org.qtproject.example.App-1Pt7KXEJt1AnzN4e1jlymg==/lib/arm/libQt6Core_armeabi-v7a.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/org.qtproject.example.App-1Pt7KXEJt1AnzN4e1jlymg==/lib/arm:/data/app/org.qtproject.example.App-1Pt7KXEJt1AnzN4e1jlymg==/base.apk!/lib/armeabi-v7a", permitted_paths="/data:/mnt/expand:/data/data/org.qtproject.example.App"] W qt.tlsbackend.ossl: : Failed to load libssl/libcrypto. W qt.network.ssl: : The backend "cert-only" does not support QSslKey W qt.network.ssl: : Active TLS backend does not support key creation
I have the
android_openssl
folder (got it from KDAB's GitHub repo) correctly installed in the ANDROID SDK folder. I even tried to manually copy the correct.so
from there to put them in...\cmake-build\Android_Qt_6_3_1_Clang_armeabi_v7a\Debug\App\android-build\libs\armeabi-v7a
but still got the same error.Also before I manually copy the relevant
.so
files theandroid-build\libs\armeabi-v7a
folder didn't have any OpenSSL related libraries inside it, so I suspect that there might be a bug in the way that the build tools handleANDROID_EXTRA_LIBS
not copying them to the right directory.Anyone might have an idea what went wrong here ?
-
Had you tried installing android_openssl with Qt Creator to your Windows 10 (assumption, please correct if wrong) host?
You could also check is the ANDROID_SDK_ROOT setup properly or replace it by absolute path like to see does it work.
if (ANDROID) include(/home/youruseridhere/Android/Sdk/android_openssl/CMakeLists.txt) endif()
-
@Omarito, we've detected a problem with the documentation - the android_openssl repository does not use the correct target property to set these extra libraries.
Until the repository has been updated, this problem can be fixed on the project side in two ways:
First method: using your current method, but add line:
set_target_properties(appssl PROPERTIES QT_ANDROID_EXTRA_LIBS "${ANDROID_EXTRA_LIBS}")
after " include(${ANDROID_SDK_ROOT}/android_openssl/CMakeLists.txt)".
Second method:
Do not include the CMakeLists.txt, but instead follow the secondary method in documentation, with updated property name:
set(QT_ANDROID_EXTRA_LIBS <path_to_libs_dir>/ibcrypto_1_1.so <path_to_libs_dir>/libssl_1_1.so CACHE INTERNAL "")
This should fix the problem. We're currently working on updating the documentation for this.
-
For posterity, building for android
arm64-v8a
with Qt 6.4.0 using cmake only required adding the step in the docs for me:set_property(TARGET <target name> PROPERTY QT_ANDROID_EXTRA_LIBS <path_to_libs_dir>/libcrypto_1_1.so <path_to_libs_dir>/libssl_1_1.so)
-
@Petriv This works also if the target is a library? In my case not!
I try also another way because In the android_openssl repository a contribuitor speaks about to call
qt_add_executable with the MANUAL_FINALIZATION flag, then include android_openssl/CMakeLists.txt (updated for Qt6) and call qt_finalize_target(...) at the end.I can say that after build a simple example this works!
But if the target is a library qt_finalize_target() macro is empty (according to qt6 docs) and the library is not builded at all!
-
Hi,
I have same errors with Qt6.5 Beta2, but it works with Qt6.4.2.
Can you help me with that ?
(I use Qt6.5 because of QtLocation is packaged with it)
-
@gween said in QT6.3 Android couldn't link with OpenSSL libs:
For posterity, building for android
arm64-v8a
with Qt 6.4.0 using cmake only required adding the step in the docs for me:set_property(TARGET <target name> PROPERTY QT_ANDROID_EXTRA_LIBS <path_to_libs_dir>/libcrypto_1_1.so <path_to_libs_dir>/libssl_1_1.so)
How you make it get the correct library from the correct directory for either the V7 V8 and X86-64 (for the emulator) ? Or I need to change that manually for each target?