qt_android_extra_libs
与目标机一起部署的额外库。
此属性在 Qt 6.0 中引入。
注意: 该属性仅用于 Android 平台。
将复制到应用程序libs
文件夹并在启动时加载的外部库列表。例如,可用于在应用程序中启用 OpenSSL。更多信息,请参阅为 Android 添加 OpenSSL 支持。
从项目的构建树中添加额外库时,还需要在库和应用程序目标之间添加依赖关系。在部署 apk 时,使用以下项目结构可能会导致问题:
qt_add_executable(MyApp main.cpp) set_target_properties(MyApp PROPERTIES QT_ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/libMyService_${ANDROID_ABI}.so ) # MyService library doesn't have any relations with MyApp qt_add_library(MyService service.cpp)
这会导致无法确定 MyService 库是否会在 MyApp 部署前可用。最简单的解决方案是将 MyService 库添加到 MyApp 依赖关系中:
add_dependencies(MyApp MyService)
在多架构项目中添加每个架构的库时,应明确列出所有库的路径,而不是依赖CMAKE_ANDROID_ARCH_ABI
等变量来动态计算路径。
更喜欢
set(libs ${CMAKE_CURRENT_BINARY_DIR}/libA_x86so ${CMAKE_CURRENT_BINARY_DIR}/libA_x86_64.so ${CMAKE_CURRENT_BINARY_DIR}/libA_arm64-v8a.so ${CMAKE_CURRENT_BINARY_DIR}/libA_armeabi-v7a.so ) set_target_properties(MyApp PROPERTIES QT_ANDROID_EXTRA_LIBS ${libs}) # When targeting precompiled libs target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC libA_${ANDROID_ABI})
over:
set_target_properties(MyApp PROPERTIES QT_ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/libA_${CMAKE_ANDROID_ARCH_ABI}.so)
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.