Building Qt OPC UA for Android with encryption support, mbedtls not found
-
wrote on 28 Jul 2021, 13:28 last edited by Xerionius
I am trying to buiild Qt OPC UA for Android with encryption support. Building without encryption support works when following these steps (Compiling for Android -> Compiling on Linux). Building for Linux with encryption support works.
When running qmake for Android by executing~/Qt/5.15.2/android/bin/qmake ..
I get:
mbedtls ................................ no
Checking the config.log file there's an error:
/home/username/Qt/5.15.2/qtopcua/config.tests/mbedtls/main.cpp:37:10: fatal error: 'mbedtls/x509.h' file not found
Qt-Version: 5.15.2
OS: Arch Linux
Android NDK: 21.3.6528147
The package mbedtls-2.27.0 is installed and includes the missing file.Do I need a certain version of mbedtls for this to work? Does mbedtls need to be compiled for Android specifically, and if so, how do I do that?
I would greatly appreciate any help.
-
wrote on 29 Jul 2021, 12:40 last edited by Xerionius
I have now tried building mbedtls 2.27.0 for Android by calling
cmake -DCMAKE_TOOLCHAIN_FILE=/home/username/Android/Sdk/ndk/21.3.6528147/build/cmake/android.toolchain.cmake -DANDROID_NDK=/home/username/Android/Sdk/ndk/21.3.6528147 -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=”arm64-v8a” -DENABLE_TESTING=false -DANDROID_NATIVE_API_LEVEL=21 ../mbedtls-mbedtls-2.27.0/ cmake –build .
Then I ran qmake, pointing to the compiled mbedtls by calling:
~/Qt/5.15.2/android/bin/qmake QMAKE_CXXFLAGS+=”-I/home/username/build-mbedtls-android/build/include/mbedtls -L/home/username/build-mbedtls-android/build/library/” ..
But I am still getting the exact same error:
fatal error: ‘mbedtls/x509.h’ file not found
In the config.log, the supplied paths aren’t listed under the “Global lib dirs” and “Global inc dirs”.
I also tried copying the source files under include/ and the built files under library/ to paths that are listed under the Global dirs respectively, which resulted in a different error:…/aarch64-linux-android/bin/ld: cannot find -lmbedx509 …/aarch64-linux-android/bin/ld: cannot find -lmbedcrypto
-
wrote on 31 Aug 2021, 09:16 last edited by
Jannis Völker helped me with this issue on the basysKom blog and thanks to him I was able to build Qt OPC UA for Android with encryption support.
Posting the solution he pointed me to in case someone else has the same issue:First build mbedtls for Android with the following commands:
cd ~ mkdir mbedtls-build cd mbedtls-build git clone https://github.com/ARMmbed/mbedtls.git mkdir build cd build cmake -DCMAKE_TOOLCHAIN_FILE=path_to_android_ndk/build/cmake/android.toolchain.cmake -DANDROID_NDK=path_to_android_ndk -DCMAKE_BUILD_TYPE=Release -DENABLE-TESTING=false -DANDROID_NATIVE_SDK_LEVEL=21 -DANDROID_ABI="arm64-v8a" ../mbedtls/ sudo cmake --build . --target install
Then build and install the OPC UA module as following:
cd ~/Qt/5.15.2/ git clone https://code.qt.io/qt/qtopcua.git cd qtopcua mkdir build cd build ~/Qt/5.15.2/android/bin/qmake .. EXTRA_INCLUDEPATH="~/mbedtls-build/mbedtls/include" EXTRA_LIBDIR="~/mbedtls-build/build/library" ANDROID_ABIS="arm64-v8a" -- -no-feature-gds make -j 8 sudo make install