Android Studio配置总结

1. CMAKE

AS 2.3.1版本后使用Cmake来配置Native代码的编译,所以在这里总结下Cmake的常用配置:

添加引用路径:

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/include)
添加待编译模块:
add_library( # Sets the name of the library.
             ImageTargetsNative
             # Sets the library as a shared library.
             SHARED
             #SHARED output .so  STATIC output .a
             # Provides a relative path to your source file(s).
             src/main/cpp/ImageTargets.cpp
             src/main/cpp/SampleAppRenderer.cpp
             src/main/cpp/SampleUtils.cpp
             src/main/cpp/Texture.cpp
              )
添加已编译好的模块:
add_library( vuforia SHARED IMPORTED )
set_target_properties(vuforia PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libVuforia.so)
添加系统待链接模块:
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 )

find_library( # Sets the name of the path variable.
              GLESv2-lib
              GLESv2)
链接输出模块:
target_link_libraries( # Specifies the target library.
                       ImageTargetsNative
                       vuforia
                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib}
                       ${GLESv2-lib}
                       )
添加编译参数和选择编译平台需要在build.grandle中进行配置:
externalNativeBuild {
    cmake {
        cppFlags "-Wno-write-strings","-Wno-psabi","-DUSE_OPENGL_ES_2_0","-std=c++11"
    }
}
ndk {
    // Specifies the ABI configurations of your native
    // libraries Gradle should build and package with your APK.
    abiFilters 'armeabi-v7a'
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值