-
新建C++项目
-
修改CMakeLists.txt, 增加一行
add_executable(single native-lib.cpp)
cmake_minimum_required(VERSION 3.4.1) add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp )
add_executable(single native-lib.cpp)
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} ) -
build apk
可执行文件在 app/build/intermediates/cmake/debug/obj/armeabi-v7a/single -
push 到 /data/local/tmp 运行
cd /data/local/tmp chmod +x ./single
./single
留言