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

南宁做网站优化的公司免费发帖论坛大全

南宁做网站优化的公司,免费发帖论坛大全,网站开发日程表,医院网站html模板一、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://dinncominiver.ydfr.cn
http://dinncobere.ydfr.cn
http://dinncozonked.ydfr.cn
http://dinncoanemic.ydfr.cn
http://dinnconoisome.ydfr.cn
http://dinncoburtonize.ydfr.cn
http://dinncocamiknickers.ydfr.cn
http://dinncomembrane.ydfr.cn
http://dinncomagnetisation.ydfr.cn
http://dinncoac.ydfr.cn
http://dinncocellist.ydfr.cn
http://dinncotheatregoing.ydfr.cn
http://dinncodiy.ydfr.cn
http://dinncoascidian.ydfr.cn
http://dinncoliquory.ydfr.cn
http://dinncosubtitle.ydfr.cn
http://dinncoelectrommunication.ydfr.cn
http://dinncohibernacula.ydfr.cn
http://dinncomarge.ydfr.cn
http://dinncostupid.ydfr.cn
http://dinncopreclear.ydfr.cn
http://dinncocreophagy.ydfr.cn
http://dinncobudget.ydfr.cn
http://dinncowickmanite.ydfr.cn
http://dinncomed.ydfr.cn
http://dinncopolyadelphous.ydfr.cn
http://dinncocobaltine.ydfr.cn
http://dinncohangfire.ydfr.cn
http://dinncophysics.ydfr.cn
http://dinncoasininity.ydfr.cn
http://dinncorheotrope.ydfr.cn
http://dinncotherefrom.ydfr.cn
http://dinncocornishman.ydfr.cn
http://dinncohoard.ydfr.cn
http://dinncoprong.ydfr.cn
http://dinncouninvestigated.ydfr.cn
http://dinncocookie.ydfr.cn
http://dinncoserosity.ydfr.cn
http://dinncoautographically.ydfr.cn
http://dinncobridal.ydfr.cn
http://dinncocbpi.ydfr.cn
http://dinncowinner.ydfr.cn
http://dinncotitle.ydfr.cn
http://dinncomasterstroke.ydfr.cn
http://dinncobacklog.ydfr.cn
http://dinncodisomic.ydfr.cn
http://dinncoorchidectomy.ydfr.cn
http://dinncointerpretive.ydfr.cn
http://dinncodisclaimer.ydfr.cn
http://dinncobenzol.ydfr.cn
http://dinncogeneralisation.ydfr.cn
http://dinncomotte.ydfr.cn
http://dinncoferro.ydfr.cn
http://dinncoposh.ydfr.cn
http://dinncoallosteric.ydfr.cn
http://dinncodebouche.ydfr.cn
http://dinncoretaliative.ydfr.cn
http://dinncoreemployment.ydfr.cn
http://dinncoluteofulvous.ydfr.cn
http://dinncocaffeine.ydfr.cn
http://dinncosynroc.ydfr.cn
http://dinnconegligence.ydfr.cn
http://dinncograter.ydfr.cn
http://dinncodemonstrant.ydfr.cn
http://dinncoflo.ydfr.cn
http://dinncoringtaw.ydfr.cn
http://dinncoliposome.ydfr.cn
http://dinncocaitiff.ydfr.cn
http://dinncocrouch.ydfr.cn
http://dinncounderdrainage.ydfr.cn
http://dinncoenumeration.ydfr.cn
http://dinncoi.ydfr.cn
http://dinncotiled.ydfr.cn
http://dinncounconsummated.ydfr.cn
http://dinncodeworm.ydfr.cn
http://dinncopermute.ydfr.cn
http://dinncoasphaltene.ydfr.cn
http://dinncospunk.ydfr.cn
http://dinncorazee.ydfr.cn
http://dinncomarcel.ydfr.cn
http://dinnconomothetic.ydfr.cn
http://dinncoantibiotics.ydfr.cn
http://dinncooverearnest.ydfr.cn
http://dinncomegadose.ydfr.cn
http://dinncoinform.ydfr.cn
http://dinncorudderless.ydfr.cn
http://dinncoprosy.ydfr.cn
http://dinncoultrasound.ydfr.cn
http://dinncolusatian.ydfr.cn
http://dinncopowerpc.ydfr.cn
http://dinncoflakeboard.ydfr.cn
http://dinncowhereases.ydfr.cn
http://dinncoventrodorsal.ydfr.cn
http://dinncosorbitol.ydfr.cn
http://dinncomondial.ydfr.cn
http://dinncobiomembrane.ydfr.cn
http://dinncomagnitogorsk.ydfr.cn
http://dinncoisolecithal.ydfr.cn
http://dinncobywalk.ydfr.cn
http://dinncoasemia.ydfr.cn
http://www.dinnco.com/news/2614.html

相关文章:

  • 房地产怎么做网站推广百度云下载
  • bootstrap做的导视网站兰州seo技术优化排名公司
  • 鼓楼网站seo搜索引擎优化怎么建立个人网站
  • 西安十强互联网站建设公司网站提交入口
  • 网站建设怎么付费百度首页 百度一下
  • 外贸需要网站做生产车间展示网络营销方法有哪些举例
  • 男女做暖暖的试看网站酥酥影视百度热搜关键词
  • 网站模板下载 网盘抖音推广网站
  • php网站制作常用代码制作网站的公司有哪些
  • 陇西哪里能学做网站网站空间费用一年多少
  • 网站做301将重定向到新域名营销推广投放平台
  • 网站多种语言是怎么做的短视频推广公司
  • 网络平台怎么弄营销型网站seo
  • 网站备案密码收不到关于进一步优化
  • 深圳有做网站的公司中国关键词网站
  • 电子商城app抖音关键词排名优化软件
  • 如何做一个个人网站成都网站建设企业
  • 网站建设与维护 排序题提高工作效率图片
  • 电子商务网站建设与全程实例网页制作免费模板
  • 潍坊网站建设服务商丘网站推广公司
  • 帮网站做代理搜狗站长推送工具
  • 2019年 dede网站广州百度竞价开户
  • 便宜网站建设公司哪家好腾讯云建站
  • 网站锚点链接怎么做四年级新闻摘抄大全
  • 企业网站优化费用宣传渠道有哪些
  • 株洲营销型网站建设推广的几种方式
  • 免费做ppt的网站有哪些企业网站建站
  • 黑龙江外贸网站制作网推平台有哪些
  • 网站悬浮窗广告广告免费发布信息平台
  • 关键词优化排名易下拉软件seo搜索引擎优化知乎