Building a toolchain with cmake to cross-compile for android

后端 未结 4 1051
后悔当初
后悔当初 2020-12-23 22:45
gcc (GCC) 4.8.1 
android-ndk-r9 

Hello,

My host machine is Fedora 19 and I want to create a tool-chain for compiling programs

4条回答
  •  难免孤独
    2020-12-23 23:23

    In 2020 the make-standalone-toolchain.sh approach is deprecated.

    This is an updated CMakeList.txt:

    set(CMAKE_SYSTEM_NAME Android)
    set(CMAKE_SYSTEM_VERSION 24)
    set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
    
    PROJECT(mylib C)
    CMAKE_MINIMUM_REQUIRED(VERSION 3.18.0)
    
    SET( ${PROJECT_NAME}_CURRENT 1 )
    SET( ${PROJECT_NAME}_REVISION 0 )
    SET( ${PROJECT_NAME}_AGE 0 )
    SET(VERSION "${${PROJECT_NAME}_CURRENT}.${${PROJECT_NAME}_REVISION}.${${PROJECT_NAME}_AGE}")
    
    
    SET(SOURCES foobar.c)
    ADD_LIBRARY(mylib SHARED ${SOURCES})
    
    

    NOTE: For the ABI arm64-v8a CMake 3.18 is needed to detect the NDK toolchain correctly, 3.10 which is the version in Ubuntu 18.04, does not find the toolchain.

提交回复
热议问题