3

I have tried several options but still didn't link the libraries successfully. I have Qt Android CMake application and I need to link the libssl and libcrypto libraries. I have placed them in the poject /android_openssl/ANDROID_ABI/lib/ and for each ABI i have this:

enter image description here

And also the include folder is next to the abi folders. I have tried this solutions but I end up without this libraries to be linked:

I tried this possible solution and I got error:

add_library(ssl STATIC IMPORTED) add_library(crypto STATIC IMPORTED) set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/android_openssl/${ANDROID_ABI}/lib/libssl.a) set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/android_openssl/${ANDROID_ABI}/lib/libcrypto.a) add_library(MyApp SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_RESOURCES} ) target_link_libraries(MyApp PRIVATE ssl crypto Qt5::Core Qt5::Quick Qt5::QuickControls2 Qt5::Sql Qt5::Network Qt5::Svg ) 

Error:

E linker : library "/system/lib/libcrypto.so" ("/system/lib/libcrypto.so") needed or dlopened by "/data/app/~~Xp7o_GB4MNRnsRrBx8X1Pw==/org.qtproject.example-VZ3Vyyfp8FGD1_RYb2Soug==/lib/x86/libQt5Core_x86.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/~~Xp7o_GB4MNRnsRrBx8X1Pw==/org.qtproject.example-VZ3Vyyfp8FGD1_RYb2Soug==/lib/x86:/data/app/~~Xp7o_GB4MNRnsRrBx8X1Pw==/org.qtproject.example-VZ3Vyyfp8FGD1_RYb2Soug==/base.apk!/lib/x86", permitted_paths="/data:/mnt/expand:/data/user/0/org.qtproject.example"] W libMyApp_x86.so: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed 

Can you please tell me what I am doing wrong? I have found so much resources on this topic but still I am doing something wrong.

Also, I see that here I have static libraries for each abi .a and also I see .so.1.1. So which one I should link?

5
  • 1
    Please show the full text of any error messages you see Commented Dec 18, 2021 at 15:59
  • @AlanBirtles I have added erorr message that i got for second solution. For the first one there is no error I only see in app that data is not received from the server so libraries are not linked. Commented Dec 18, 2021 at 16:10
  • which ones should I link, shared or static? Commented Dec 18, 2021 at 16:30
  • 2
    Static will probably make your life easier, the error is probably due to the missing symlink from libcrypto.so to libcrypto.so.1.1 Commented Dec 18, 2021 at 16:43
  • @AlanBirtles I have tried with static and got another error. I have updated the question with my last try. Do you have any suggestion what to try or have you encountered similar error? Thanks in advance. Commented Dec 18, 2021 at 21:16

1 Answer 1

1

By looking at the error it seems that "libQt5Core_x86.so" is looking for "libcrypto.so" and cannot find it. That is expected since OpenSSL builds ".so.1.1" library files.

To solve this there you should:

1 - Rebuild OpenSSL for Android without .1.1. There are some answers on Stack Overflow and scripts on Github to do this but running make SHLIB_VERSION_NUMBER= SHLIB_EXT=.so on newer versions of OpenSSL should do the trick. Any doubts for other android related stuff use this guide: https://doc.qt.io/qt-6/android-openssl-support.html#building-openssl-for-android

2 - Use Qt creator to get the OpenSSL handy include project as this screenshot shows. (This is a mac screenshot, but in Linux look for Tools > Options > Devices > Android > Android OpenSSL Settings

3 - Finally follow change CMakeLists.txt to use the project above and add the OpenSSL library files using QT_EXTRA_LIBS. Use this guide: https://doc.qt.io/qt-6/android-openssl-support.html#using-openssl-libraries-with-qt-for-android

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.