1. build.gradle的android{}下加入
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-24', '-DANDROID_STL=c++_static', '-DANDROID_STL=c++_shared'
}
}
2. 下载编译好的lib
https://github.com/Tencent/ncnn/releases
ncnn-android-vulkan-lib.zip
3. CMakeLists.txt
add_library(glslang STATIC IMPORTED)
add_library(OGLCompiler STATIC IMPORTED)
add_library(OSDependent STATIC IMPORTED)
add_library(SPIRV STATIC IMPORTED)
set_target_properties(glslang PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/lib/${ANDROID_ABI}/libglslang.a)
set_target_properties(OGLCompiler PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/lib/${ANDROID_ABI}/libOGLCompiler.a)
set_target_properties(OSDependent PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/lib/${ANDROID_ABI}/libOSDependent.a)
set_target_properties(SPIRV PROPERTIES IMPORTED_LOCATION ${distribution_DIR}/lib/${ANDROID_ABI}/libSPIRV.a)
add_library(ncnn SHARED IMPORTED)
set_target_properties(ncnn
PROPERTIES
IMPORTED_LOCATION
${distribution_DIR}/lib/${ANDROID_ABI}/libncnn.a
)
target_include_directories(native-lib PRIVATE
${distribution_DIR}/include/ncnn
)
target_link_libraries( # Specifies the target library.
native-lib
ncnn
glslang SPIRV OGLCompiler OSDependent
vulkan
z
jnigraphics
${log-lib})
网友评论