【QT for Android】拷贝so库依赖文件

CMAKE文件添加ANDROID相关设置

SET(QT_DIR    ## Qt安装路径的环境变量
	${QT_DIR} CACHE PATH  "Qt root path"
)

IF("${QT_DIR}" STREQUAL "")
    MESSAGE(FATAL_ERROR "Please set the Qt install path first. -DQT_DIR=XXXX ")
ENDIF()

#set(QT_DIR "D:/Qt/Qt5.12.0/5.12.0/android_x86")

if("${QT_DIR}" MATCHES "android_arm64_v8a")
	set(ANDROID_ABI arm64-v8a)
elseif("${QT_DIR}" MATCHES "android_armv7")
	set(ANDROID_ABI armeabi-v7a)
elseif("${QT_DIR}" MATCHES "android_x86")
	set(ANDROID_ABI x86)
elseif()
	message(ANDROID_ABI is not set)
endif()

IF(NOT ("${ANDROID_ABI}" STREQUAL ""))

	if($ENV{ANDROID_NDK})
		# 没有找到JAVA_HOME环境变量
		message(FATAL_ERROR "not defined environment variable:ANDROID_NDK")  
	endif()

	set(ANDROID_NDK $ENV{ANDROID_NDK})
	message(ANDROID_NDK:${ANDROID_NDK})
	#set(ANDROID_NDK D:/Android/android-ndk-r20-windows-x86_64/android-ndk-r20)
	set(CMAKE_TOOLCHAIN_FILE ${ANDROID_NDK}/build/cmake/android.toolchain.cmake)
	set(CMAKE_MAKE_PROGRAME ${ANDROID_NDK}/prebuilt/windows-x86_64/bin/make.exe)
	set(ANDROID_TOOLCHAIN clang)
	set(ANDROID_PLATFORM android-24)
	set(ANDROID_STL c++_shared)
	set(ANDROID_SYSROOT ${ANDROID_NDK}/sysroot)
	set(INSOURCEBUILD 1)

	set(Qt5_DIR "${QT_DIR}/lib/cmake/Qt5")
	set(Qt5Core_DIR "${QT_DIR}/lib/cmake/Qt5Core")
	set(Qt5Gui_DIR "${QT_DIR}/lib/cmake/Qt5Gui")
	set(Qt5Widgets_DIR "${QT_DIR}/lib/cmake/Qt5Widgets")
	set(Qt5Sql_DIR "${QT_DIR}/lib/cmake/Qt5Sql")
	set(Qt5WebEngine_DIR "${QT_DIR}/lib/cmake/Qt5WebEngine")
	set(Qt5WebEngineWidgets_DIR "${QT_DIR}/lib/cmake/Qt5WebEngineWidgets")
	set(Qt5WebChannel_DIR "${QT_DIR}/lib/cmake/Qt5WebChannel")
	set(Qt5Network_DIR "${QT_DIR}/lib/cmake/Qt5Network")
	set(Qt5WebSockets_DIR "${QT_DIR}/lib/cmake/Qt5WebSockets")
	set(Qt5Concurrent_DIR "${QT_DIR}/lib/cmake/Qt5Concurrent")
	set(Qt5Quick_DIR "${QT_DIR}/lib/cmake/Qt5Quick")

	# set(ANDROID_ABI x86)
	if(${ANDROID_ABI} STREQUAL "armeabi-v7a") 
		set(ANDROID_ABI_NAME  "android_armv7")
		MESSAGE( "is armeabi-v7a")
		include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi) 
	elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") 
		MESSAGE( "is arm64-v8a")
		set(ANDROID_ABI_NAME  "android_arm64_v8a")
		include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android) 
	elseif(${ANDROID_ABI} STREQUAL "x86") 
		MESSAGE( "is x86")
		set(ANDROID_ABI_NAME  "android_x86")
		include_directories(${ANDROID_SYSROOT}/usr/include/i686-linux-android) 
	else() 
		MESSAGE( "is else")
		set(ANDROID_ABI_NAME  "android_x86")
		include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi) 
	endif()
endif()

拷贝so库依赖文件

在编译好的SO库目录下创建json文件

json 文件名:android-libtest.so-deployment-settings.json

{
   "description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
   "qt": "D:/Qt/Qt5.12.0/5.12.0/android_x86",
   "sdk": "C:/Users/HiWin10/AppData/Local/Android/Sdk",
   "sdkBuildToolsRevision": "29.0.2",
   "ndk": "D:\\Android\\android-ndk-r20-windows-x86_64\\android-ndk-r20",
   "toolchain-prefix": "x86",
   "tool-prefix": "i686-linux-android",
   "toolchain-version": "4.9",
   "ndk-host": "windows-x86_64",
   "target-architecture": "x86",
   "android-platform":"android-24",
	"ant":"D:\\Android\\apache-ant-1.10.7-bin\\apache-ant-1.10.7\\bin\\ant.bat",
   "stdcpp-path": "D:\\Android\\android-ndk-r20-windows-x86_64\\android-ndk-r20/sources/cxx-stl/llvm-libc++/libs/x86/libc++_shared.so",
   "install_root":"D:/dart_demo/export/lib/x86/output",
   "application-binary": "D:/dart_demo/export/lib/x86/libtest.so"
}

拷贝so库依赖文件

打开cmd,输入
“D:\Qt\Qt5.12.0\5.12.0\android_x86\bin\androiddeployqt.exe” --input D:\dart_demo\export\lib\x86\android-libtest.so-deployment-settings.json --output D:\dart_demo\export\lib\x86\output

ok

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巧笑笑笑倩兮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值