我可以从 git 下载 Qt 源并将其签出到 5.15.2 并为 android 编译它。我已经在 Qt Creator 中创建了它的工具包,它成功地构建了我的应用程序。但是我怎么能在没有 qt creator 的终端中做到这一点
我试过以下: -
export QT_ROOT=/home/noone/Development/KDE/Qt/build/installation
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE:String=Release \
-DQT_QMAKE_EXECUTABLE:STRING=$QT_ROOT/bin/qmake \
-DCMAKE_PREFIX_PATH:STRING=/home/noone/untitled1/build/installation \
-DCMAKE_C_COMPILER:STRING=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang \
-DCMAKE_CXX_COMPILER:STRING=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ \
-DANDROID_NATIVE_API_LEVEL:STRING=16 \
-DANDROID_NDK:PATH=$ANDROID_NDK \
-DCMAKE_TOOLCHAIN_FILE:PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI:STRING=armeabi-v7a \
-DANDROID_SDK:PATH=$ANDROID_HOME \
-DANDROID_STL:STRING=c++_shared \
-DCMAKE_FIND_ROOT_PATH:PATH=$QT_ROOT
但它给出了以下错误: -
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /optHDD/AndroidNDK/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):
Could not find a package configuration file provided by "ECM" (requested
version 5.74) with any of the following names:
ECMConfig.cmake
ecm-config.cmake
Add the installation prefix of "ECM" to CMAKE_PREFIX_PATH or set "ECM_DIR"
to a directory containing one of the above files. If "ECM" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
See also "/home/noone/untitled1/build/CMakeFiles/CMakeOutput.log".
这是我的 CMakeLists.txt:-
cmake_minimum_required(VERSION 3.14)
project(untitled1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
if(ANDROID)
add_library(untitled1 SHARED
main.cpp
qml.qrc
)
else()
add_executable(untitled1
main.cpp
qml.qrc
)
endif()
target_compile_definitions(untitled1
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(untitled1
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)