美文网首页
Android: ncnn gpu运行配置

Android: ncnn gpu运行配置

作者: wzNote | 来源:发表于2020-07-22 09:20 被阅读0次

    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})
    

    相关文章

      网友评论

          本文标题:Android: ncnn gpu运行配置

          本文链接:https://www.haomeiwen.com/subject/rzcafktx.html