android studio ndk编译原生可执行文件

来源:互联网 发布:java log4j mongodb 编辑:程序博客网 时间:2024/06/05 02:04

修改CMakeLists.txt文件

cmake_minimum_required(VERSION 3.4.1)set(CMAKE_VERBOSE_MAKEFILE on)set(EXECUTABLE_OUTPUT_PATH      "${CMAKE_CURRENT_SOURCE_DIR}/src/main/assets/${ANDROID_ABI}")
add_executable(xxxx ${CMAKE_CURRENT_SOURCE_DIR}/xxxx.cpp)target_include_directories (mybinary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library( # Sets the name of the library.             xxxxlib             # Sets the library as a shared library.             SHARED             # Provides a relative path to your source file(s).             # Associated headers in the same location as their source             # file are automatically included.             ${CMAKE_CURRENT_SOURCE_DIR}/xxxxlib.cpp )

修改gradle.build文件

externalNativeBuild {        cmake {            path "CMakeLists.txt"        }    }    defaultConfig {        externalNativeBuild {            cmake {                targets "xxxxlib", "xxxx"                arguments "-DANDROID_TOOLCHAIN=clang"                cFlags "-DTEST_C_FLAG1", "-DTEST_C_FLAG2"                cppFlags "-DTEST_CPP_FLAG2", "-DTEST_CPP_FLAG2"                abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64'            }        }    }

原文链接:http://stackoverflow.com/questions/38917297/compile-and-use-abi-dependent-executable-binaries-in-android-with-android-studio

0 0
原创粉丝点击