Android已有工程支持c++ 使用CMake
来源:互联网 发布:ubuntu如何挂载磁盘 编辑:程序博客网 时间:2024/06/05 00:56
Android 已有项目添加c++支持
1、右键module新建CMakeLists.txt
2.module中build.gradle配置文件中在
3、CMakeLists.txt文件编写规则
1、右键module新建CMakeLists.txt
2.module中build.gradle配置文件中在
android{ defaultConfig { externalNativeBuild { cmake { cppFlags "" } } ndk {//编译在哪个CPU平台上 abiFilters 'armeabi-v7a' } sourceSets.main {//外部so文件路径 jniLibs.srcDir 'libs' } } externalNativeBuild { // Encapsulates your CMake build configurations. cmake { // Provides a relative path to your CMake build script. path "CMakeLists.txt" } }}
3、CMakeLists.txt文件编写规则
cmake_minimum_required(VERSION 3.4.1)add_library( # 为library起名字 native-lib # 设置为SHARE类型,STATIC为需要加载.a文件 SHARED # 需要编译的源代码文件目录 src/main/cpp/native-lib.cpp )add_library( avcodec-57# 为library起名字 SHARED IMPORTED ) # 不需要编译,由外部导入set_target_properties( avcodec-57 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libavcodec-57.so )//配置导入文件的路径add_library( avfilter-6 SHARED IMPORTED )set_target_properties( avfilter-6 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libavfilter-6.so )add_library( avformat-57 SHARED IMPORTED )set_target_properties( avformat-57 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libavformat-57.so )add_library( avutil-55 SHARED IMPORTED )set_target_properties( avutil-55 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libavutil-55.so )add_library( swresample-2 SHARED IMPORTED )set_target_properties( swresample-2 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libswresample-2.so )add_library( swscale-4 SHARED IMPORTED )set_target_properties( swscale-4 PROPERTIES IMPORTED_LOCATION ../../../../libs/armeabi-v7a/libswscale-4.so )include_directories( libs/include )#外部库需要的头文件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 )//加载NDK上的library# Specifies libraries CMake should link to your target library. You# can link multiple libraries, such as libraries you define in this# build script, prebuilt third-party libraries, or system libraries.#将需要的库文件进行链接target_link_libraries( # Specifies the target library. native-lib avcodec-57 avfilter-6 avformat-57 avutil-55 swresample-2 swscale-4 # Links the target library to the log library # included in the NDK. ${log-lib} )
阅读全文
0 0
- Android已有工程支持c++ 使用CMake
- 【CMake】已有项目添加JNI支持
- 已有Android工程集成Unity工程
- 已有Android工程集成PhoneGap页面
- 已有Android工程集成ReactNative页面
- 已有Android工程集成DCloud页面
- React Native 已有android工程集成
- 使用eclipse怎样打开已有工程
- 使用eclipse怎样打开已有工程
- 如何使用eclipse打开已有工程
- 如何使用eclipse打开已有工程
- 使用eclipse怎样打开已有工程
- 如何使用eclipse打开已有工程
- 如何使用eclipse打开已有工程
- 使用eclipse打开已有工程
- 如何使用eclipse打开已有工程
- 使用eclipse怎样打开已有工程
- 如何使用Eclipse打开已有工程
- Assertion failed on expression: 'IsMatrixValid(matrix)'
- 学习笔记——TCP协议
- ExtJs CheckboxSelectionModel 全选操作后 清空表格头的checkBox
- 数获得数组的长度
- RecyclerView 之Adapter的简化过程浅析
- Android已有工程支持c++ 使用CMake
- 《操作系统真象还原》-阅读笔记(上)
- asp.net mvc 路由功能
- 解决手势与tableview点击事件冲突:
- bzoj 4842: [Neerc2016]Delight for a Cat (费用流)
- wps 加下拉框 来源手动填写
- BMP文件学习笔记(二):将BMP格式RGB真彩色图片转换成灰度图片
- Ubuntu下glfw的安装与使用
- 30天自制操作系统之RachelOS DAY 3