当前位置: 首页 > news >正文

做私房蛋糕在哪些网站写东西百度官方下载

做私房蛋糕在哪些网站写东西,百度官方下载,佛山网络优化推广公司,三十分钟激励视频素材一、CMake工具的介绍 如图所示,CMake工具的主要作用是,将C/C编写的native源文件编译打包生成库文件(包含动态库或者静态库文件),集成到Android中使用。 二、CMake编译工具的使用 使用主要是配置两个文件:CM…

一、CMake工具的介绍

如图所示,CMake工具的主要作用是,将C/C++编写的native源文件编译打包生成库文件(包含动态库或者静态库文件),集成到Android中使用。

二、CMake编译工具的使用

 使用主要是配置两个文件:CMakeList.txt和build.gradle

1、CMakeList.txt介绍

文件路径如下:

 文件默认的内容如下:(没加#号的都是配置)

cmake_minimum_required(VERSION 3.22.1)# Declares and names the project.project("testnative")# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.add_library( # Sets the name of the library.testnative# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).native-lib.cpp)# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.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)# 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.testnative# Links the target library to the log library# included in the NDK.${log-lib})

1.cmake_minimum_required(VERSION 3.22.1)

表示项目支持的最低cmake工具版本是3.22.1

2.

add_library( # Sets the name of the library.testnative# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).native-lib.cpp)

表示的是添加库,定义生成的库的名称、类型、指定的源码

testnative就是指定库的名称;

SHARED就是指定生成库的类型:动态|静态;

native-lib.cpp就是要编译的源码的相对CMakeList.txt的路径,相对路径;

3.

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里面的log库,并将库的路径赋值给了log-lib变量,相当于java中定义了一个变量log-lib,值是log。

4.

target_link_libraries( # Specifies the target library.testnative# Links the target library to the log library# included in the NDK.${log-lib})

就是链接库。将特定库链接到目标库,这是是将上面定义的log-lib链接到我们的testnative,这里的${log-lib}就是将log-lib的值取出来,链接到我们的testnative,这样我们就可以使用log库了。

2、module下的build.gradle配置了CMake的介绍

文件路径如下:

 打开文件看下如下配置:

 CMake在android{}闭包中做了如下配置:

externalNativeBuild {cmake {path file('src/main/cpp/CMakeLists.txt')version '3.22.1'}}

这里这个配置,配置了CMakeList.txt文件的路径(路径是相对于项目的)和编译使用的cmake的版本。

另外我们还可以在defaultConfig闭包下配置其他信息(C/C++标准库的支持版本),如下:

 上面这个配置可以不写,使用默认的就行。以下是一个配置样例:

这里配置的C++标准库是动态类型(静态库就不需要指定),这样编译后会在build中生成一个标准库文件。

加之前的是:

加之后的是:

 这里顺便介绍一下C++标准库是什么:

 三、Android中如何生成的so库

 以上代码就能将so库加载到程序中,然后就可以调用相关的native的api,从而就基于JNI来调用so库里面的功能。

编写相关的代码:

在Java端,我们编写一个native的方法:

 对应到C/C++中的代码就是:

 Java端通过调用stringFromJNI()就能调用到C/C++端的这段代码,这就是JNI的使用。

效果:Android界面显示了C++函数中的字符串。

 

http://www.ds6.com.cn/news/25263.html

相关文章:

  • 高明网站设计多少钱seo课程多少钱
  • 有没有帮别人做图片的网站赚钱广州:推动优化防控措施落
  • 建公司网站需要多少钱关键词搜索指数
  • 中小企业网站推广企业品牌推广营销方案
  • 怎么测网站流量吗外贸建站平台
  • wordpress自带ajax失效抖音seo排名优化
  • 用粉色做网站主题色怎么做个网站
  • 企业交易平台的网站制作多少钱株洲最新今日头条
  • 专门做情侣装的网站推广注册app赚钱平台
  • 做网站可以干什么网站关键词优化方案
  • 厦门律师网站建设商品关键词怎么优化
  • 中陕核建设集团网站网站优化最为重要的内容是
  • 免费网站建设步骤最新时事热点
  • 水泥公司网站建设简单网页制作成品和代码
  • 保洁公司用哪些网站做推广附近的教育培训机构有哪些
  • 网站建设公司模板天猫seo搜索优化
  • 网站ui怎么做的今日冯站长之家
  • 网站建设教程 三级分销推广普通话的意义简短
  • 可靠的网站建设图微信营销典型案例
  • 视频网站做cpa怎么做好网络销售
  • 做网站费用可以看为广告费用吗网站策划是做什么的
  • 购物网站开发原理seo公司哪家好用
  • wap网站开发技术广告优化
  • 网站建设报价东莞重庆seo小z博客
  • 餐饮网站制作seo整站优化新站快速排名
  • 禹州做网站的营销是什么意思
  • 男人和女人做羞羞的事情网站网站排名seo
  • wordpress是动态网站吗下载优化大师app
  • 网站右下角代码关键词排名优化官网
  • 网站空间域名续费站长之家查询的网址