Qt6 running an example from the documentation
-
wrote on 22 Jan 2024, 21:01 last edited by JoeCFD
@Ivelin I am not sure if your app is built. I have a dir android-build which you do not have.
run
locate .apknormally better to
mkdir build
cd build
cmake ..
makecmake has messy stuff which you do not want it in your project dir.
-
wrote on 22 Jan 2024, 21:29 last edited by
@Ivelin take a look at how to pass Android settings to cmake file.
https://developer.android.com/ndk/guides/cmake
What you did will not build. -
@Ivelin take a look at how to pass Android settings to cmake file.
https://developer.android.com/ndk/guides/cmake
What you did will not build.wrote on 22 Jan 2024, 23:39 last edited by@JoeCFD, thank you for providing this information. I have clearer picture right now, but I got another problem
At the moment after I do
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=26 .
I get
-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:16 (find_package): By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one. Could not find a package configuration file provided by "Qt6" with any of the following names: Qt6Config.cmake qt6-config.cmake Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred! See also "/home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier/CMakeFiles/CMakeOutput.log".
which is weird because when I do
cmake .
only
I get
-- The CXX compiler identification is GNU 9.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Could NOT find Qt6WidgetsTools (missing: Qt6WidgetsTools_DIR) CMake Warning at /home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package): Found package configuration file: /home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered to be NOT FOUND. Reason given by package: Target "Qt6::Widgets" was not found. Call Stack (most recent call first): CMakeLists.txt:16 (find_package) -- Configuring done -- Generating done -- Build files have been written to: /home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier
Why is that ? Could you help me out ?
-
@JoeCFD, thank you for providing this information. I have clearer picture right now, but I got another problem
At the moment after I do
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=26 .
I get
-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:16 (find_package): By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one. Could not find a package configuration file provided by "Qt6" with any of the following names: Qt6Config.cmake qt6-config.cmake Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred! See also "/home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier/CMakeFiles/CMakeOutput.log".
which is weird because when I do
cmake .
only
I get
-- The CXX compiler identification is GNU 9.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Could NOT find Qt6WidgetsTools (missing: Qt6WidgetsTools_DIR) CMake Warning at /home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package): Found package configuration file: /home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered to be NOT FOUND. Reason given by package: Target "Qt6::Widgets" was not found. Call Stack (most recent call first): CMakeLists.txt:16 (find_package) -- Configuring done -- Generating done -- Build files have been written to: /home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier
Why is that ? Could you help me out ?
-
@Ivelin Can you try?
CMAKE_PREFIX_PATH "/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6"wrote on 23 Jan 2024, 00:37 last edited by@JoeCFD said in Qt6 running an example from the documentation:
/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6"
I have set it in the CMakeLists.txt file as
set(CMAKE_PREFIX_PATH "/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6")
Now I get
-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning at CMakeLists.txt:15 (find_package): By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one. Could not find a package configuration file provided by "Qt6" with any of the following names: Qt6Config.cmake qt6-config.cmake Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed. CMake Error at CMakeLists.txt:26 (qt_add_executable): Unknown CMake command "qt_add_executable". -- Configuring incomplete, errors occurred! See also "/home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier/CMakeFiles/CMakeOutput.log".
-
@Ivelin Can you try?
CMAKE_PREFIX_PATH "/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6" -
@JoeCFD, perhaps something is wrong with my toolchain file?
I have downloaded this Qt from Qt creator and I got my ndk, sdk and toolchain file ask from the Android Studio
-
@Ivelin Can you try?
CMAKE_PREFIX_PATH "/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6"wrote on 23 Jan 2024, 14:44 last edited by Ivelin@JoeCFD, I have made some progress.
As I said I have downloaded Qt6 from the Qt Maintenance. I looked in the Qt/6.2.4 folder and saw there there is a qt.toolchain.cmake file in Qt/6.2.4/android_x86_64/lib/cmake/Qt6/qt.toolchain.cmake, so I used that one.
It gave me an error that it is searching for /opt/android/android-ndk-r22b, but I hadn't had /opt/android, so I created a folder and downloaded the anroid-ndk-r22b file from the official android ndk downloads. It was also searching for an sdk, but I already had one ( Don't remember where I got it from )
After that I ran this command:
cmake -DCMAKE_TOOLCHAIN_FILE=/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6/qt.toolchain.cmake .
I got
-- The CXX compiler identification is Clang 11.0.5 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Performing Test HAVE_EGL -- Performing Test HAVE_EGL - Success -- Found EGL: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include (found version "1.5") -- Performing Test HAVE_GLESv2 -- Performing Test HAVE_GLESv2 - Success -- Found GLESv2: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -- Found WrapVulkanHeaders: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -- Found android platform plugin at: /home/ivelin/Qt/6.2.4/android_x86_64/./plugins/platforms/libplugins_platforms_qtforandroid_x86_64.so -- Configuring done -- Generating done -- Build files have been written to: /home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier
which seems like a successful build. Then I ran make and got
Why is that ? Any ideas on how to fix it ?
-
@JoeCFD, I have made some progress.
As I said I have downloaded Qt6 from the Qt Maintenance. I looked in the Qt/6.2.4 folder and saw there there is a qt.toolchain.cmake file in Qt/6.2.4/android_x86_64/lib/cmake/Qt6/qt.toolchain.cmake, so I used that one.
It gave me an error that it is searching for /opt/android/android-ndk-r22b, but I hadn't had /opt/android, so I created a folder and downloaded the anroid-ndk-r22b file from the official android ndk downloads. It was also searching for an sdk, but I already had one ( Don't remember where I got it from )
After that I ran this command:
cmake -DCMAKE_TOOLCHAIN_FILE=/home/ivelin/Qt/6.2.4/android_x86_64/lib/cmake/Qt6/qt.toolchain.cmake .
I got
-- The CXX compiler identification is Clang 11.0.5 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Performing Test HAVE_EGL -- Performing Test HAVE_EGL - Success -- Found EGL: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include (found version "1.5") -- Performing Test HAVE_GLESv2 -- Performing Test HAVE_GLESv2 - Success -- Found GLESv2: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -- Found WrapVulkanHeaders: /opt/android/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -- Found android platform plugin at: /home/ivelin/Qt/6.2.4/android_x86_64/./plugins/platforms/libplugins_platforms_qtforandroid_x86_64.so -- Configuring done -- Generating done -- Build files have been written to: /home/ivelin/Qt/Examples/Qt-6.2.4/corelib/platform/androidnotifier
which seems like a successful build. Then I ran make and got
Why is that ? Any ideas on how to fix it ?
-
@Ivelin Read the error messages. Install Android studio and then use it to install SDK build tool 30.0.2.
wrote on 23 Jan 2024, 16:02 last edited by@JoeCFD, sorry that was a stupid mistake from mine.
I have installed the corresponding SDK from Android Studio and moved the file from where the Android Studio was configured to download it to where qt6 cmake is searching for it - /opt/android and now it is working.
Thank you for your patience and support. I wouldn't make it without your patience and guidance.
Cheers.
-
17/18