I've successfully configured and built some Qt5 applications for Android using CMake and this CMake utility.
Everything worked fine until I switched from Qt5.6 to Qt5.7. When I try to configure I get an CMake error which doesn't help me much:
-- Configuring done
CMake Error in CMakeLists.txt:
No known features for CXX compiler
"GNU"
version 4.9.
-- Generating done
-- Build files have been written to: /path/to/build-dir
I run CMake like this:
ANDROID_SDK=/path/to/android-sdk-linux \
ANDROID_NDK=/path/to/android-ndk-r12 \
QT_ANDROID_ROOT=/path/to/Qt-5.7.0-android \
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk \
ANT=/usr/bin/ant \
cmake /path/to/CMakeLists.txt \
-DCMAKE_PREFIX_PATH=$QT_ANDROID_ROOT \
-DCMAKE_TOOLCHAIN_FILE=/path/to/android.toolchain.cmake
I can reproduce this behavior with a minimal C++ program:
#include <iostream>
int main() { std::cout << "hi" << std::endl; }
and a minimal CMakeLists.txt
:
cmake_minimum_required(VERSION 3.1)
find_package(Qt5Core)
add_executable(foo main.cpp)
target_link_libraries(foo Qt5::Core)
The line that introduces this error is target_link_libraries(foo Qt5::Core)
- without it the program configures and compiles fine.
Here are some things I tried:
use different NDK API levels by setting ANDROID_NATIVE_API_LEVEL
to android-8
, 9
, 16
, 18
and some other values that worked somwhere else (building Qt5.7 automatically uses android-16
)
use different NDK
releases (10e worked for me with Qt5.6, current is 12)
tried prebuilt Qt5.7 rather than home-grown from GitHub
Until now I just combined different versions of SDK/NDK/Qt/NDK_API_LEVEL but honestly I just don't know what I'm doing..
You could help me by:
The Android NDK supports using CMake to compile C and C++ code for your application. This page discusses how to use CMake with the NDK via the Android Gradle Plugin's ExternalNativeBuild or when invoking CMake directly.
CMake: an external build tool that works alongside Gradle to build your native library. You do not need this component if you only plan to use ndk-build. LLDB: the debugger Android Studio uses to debug native code. By default, LLDB will be installed alongside Android Studio.
As a workaround (from here) you can comment out the line
set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)
in lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With