CMAKE交叉编译Android库

Posted lligen-dai

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMAKE交叉编译Android库相关的知识,希望对你有一定的参考价值。

CMAKE交叉编译android

不管是在Windows,还是Ubuntu平台,

cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21/build/cmake/android.toolchain.cmake -DANDROID_NDK=F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21 -DCMAKE_SYSTEM_NAME=Android -DANDROID_PLATFORM=android-27 -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=arm64-v8a -DAndroid=ON -DANDROID_STL=c++_static -DCMAKE_CXX_STANDARD=11 -DANDROID_NATIVE_API_LEVEL=21 ..

-- Check for working C compiler: F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: F:/Download/android-ndk-r21-windows-x86_64/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_HOST_SYSTEM_NAME: Windows
-- CMAKE_HOST_SYSTEM_VERSION: 10.0.17763
-- CMAKE_HOST_SYSTEM_PROCESSOR: AMD64
-- CMAKE_HOST_SYSTEM: Windows-10.0.17763
-- CMAKE_SYSTEM_NAME: Android
-- CMAKE_SYSTEM_VERSION: 1
-- CMAKE_SYSTEM_PROCESSOR: armv7-a
-- CMAKE_SYSTEM: Android-1

一定记得是外部指定CMAKE_TOOLCHAIN_FILE,在CMakeLists.txt内部指定是会出错的(而且是在make阶段报错,cmake阶段不报),且错误千奇百怪,切记切记~

以上是关于CMAKE交叉编译Android库的主要内容,如果未能解决你的问题,请参考以下文章

CMAKE交叉编译Android库

CMAKE交叉编译Android库

x86 平台代码移植到 嵌入式平台[交叉编译三方库]

音视频交叉编译动态库静态库的学习

cmake:arm-xm-linux交叉编译工具链文件及交叉支持HTTPS的curl静态库

cmake:arm-xm-linux交叉编译工具链文件及交叉支持HTTPS的curl静态库