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

滁州市南谯区建设局网站seo算法培训

滁州市南谯区建设局网站,seo算法培训,电影购票网站开发背景,百度企业文件结构(选中的为生成的) CMake构建不需要执行命令,会自动生成so文件打包进apk Android mk构建需要执行命令生成so文件,再打包进apk。命令如下。 # 在jni目录下执行 # 生成com_demo_cppproject_OtherNdkTest.h头文件 javac -h .…

文件结构(选中的为生成的)
在这里插入图片描述
CMake构建不需要执行命令,会自动生成so文件打包进apk
Android mk构建需要执行命令生成so文件,再打包进apk。命令如下。


# 在jni目录下执行
# 生成com_demo_cppproject_OtherNdkTest.h头文件
javac -h ./ ../java/com/demo/cppproject/OtherNdkTest.java
# 构建出so文件
ndk-build NDK_PROJECTPATH=. NDK_APPLICATION_MK=Application.mk NDK_BUILD_SCRIPT=Android.mk NDK_LIBS_OUT=..\jniLibs\

MainActivity.java

package com.demo.cppproject;
public class MainActivity extends AppCompatActivity {// Used to load the 'cppproject' library on application startup.static {System.loadLibrary("cppproject");System.loadLibrary("DEMO");}private ActivityMainBinding binding;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);binding = ActivityMainBinding.inflate(getLayoutInflater());setContentView(binding.getRoot());TextView tv = binding.sampleText;String temp = stringFromJNI() + "\n" + new MyNdkTest().getData() + "\n"+ new OtherNdkTest().getName() + "==" + new OtherNdkTest().count();tv.setText(temp);}public native String stringFromJNI();
}

MyNdkTest.java

package com.demo.cppproject;public class MyNdkTest {public native String getData();
}

OtherNdkTest.java

package com.demo.cppproject;public class OtherNdkTest {public native String getName();public native  int  count();
}

CMakeLists.txt

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html# Sets the minimum version of CMake required to build the native library.cmake_minimum_required(VERSION 3.22.1)# Declares and names the project.project("cppproject")# 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.cppproject# 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.cppproject# Links the target library to the log library# included in the NDK.${log-lib})

native-lib.cpp

#include <assert.h>
#include <jni.h>
#include <string>#ifndef _Included_com_demo_cppproject_MyNdkTest
#define _Included_com_demo_cppproject_MyNdkTest
#ifdef __cplusplus
extern "C" {
#endifJNIEXPORT jstring JNICALL Java_com_demo_cppproject_MainActivity_stringFromJNI(JNIEnv *env,jobject /* this */) {std::string hello = "静态注册!cmake构建!Hello from C++";return env->NewStringUTF(hello.c_str());
}// 定义的对应java中的定义native方法, 采用动态注册
//extern "C" JNIEXPORT jstring JNICALL Java_com_demo_cppproject_MyNdkTest_getData(
JNIEXPORT jstring JNICALL getData(JNIEnv *env,jobject /* this */) {std::string hello = "动态注册!cmake构建!get data";return env->NewStringUTF(hello.c_str());
}//需要动态注册的native方法所在的类
#define JNIREG_CLAS_MAIN "com/demo/cppproject/MyNdkTest"//创建JNINativeMethod的数组,用来存放,JNINativeMethod结构变量,
// JNINativeMethod结构存放:注册的native方法,对应的签名,C++/C的对应的JNI方法
static JNINativeMethod gMethods[] = {{"getData", "()Ljava/lang/String;", (void*)getData}
};static int registerNativeMethods(JNIEnv *env, const char *className,JNINativeMethod *gMethods, int numMethods) {jclass clazz;clazz = env->FindClass(className);if (clazz == NULL) {return JNI_FALSE;}if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {return JNI_FALSE;}return JNI_TRUE;
}/***
* 注册native方法
*/
static int registerNatives(JNIEnv *env) {if (!registerNativeMethods(env, JNIREG_CLAS_MAIN, gMethods,sizeof(gMethods) / sizeof(gMethods[0]))) {return JNI_FALSE;}return JNI_TRUE;
}/**
* 如果要实现动态注册,这个方法一定要实现
* 动态注册工作在这里进行
*/
JNIEXPORT jintJNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {JNIEnv *env = NULL;jint result = -1;if (vm->GetEnv((void **) &env, JNI_VERSION_1_4) != JNI_OK) {return -1;}assert(env != NULL);if (!registerNatives(env)) { //注册return -1;}result = JNI_VERSION_1_4;return result;
}#ifdef __cplusplus
}
#endif
#endif

demo.cpp

//
// Created by Admins on 2023/5/6.
//
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#include <string>
/* Header for class com_demo_cppproject_MyNdkTest */#ifndef _Included_com_demo_cppproject_OtherNdkTest
#define _Included_com_demo_cppproject_OtherNdkTest
#ifdef __cplusplus
extern "C" {
#endif
/** Class:     com_demo_cppproject_MyNdkTest* Method:    getData* Signature: ()Ljava/lang/String;*/
JNIEXPORT jstring JNICALL Java_com_demo_cppproject_OtherNdkTest_getName(JNIEnv *env, jobject){std::string hello = "静态注册!Android mk构建!Hi from C++";return env->NewStringUTF(hello.c_str());
}/** Class:     com_demo_cppproject_MyNdkTest* Method:    count* Signature: ()I*/
JNIEXPORT jint JNICALL Java_com_demo_cppproject_OtherNdkTest_count(JNIEnv *env, jobject){return 11;
}#ifdef __cplusplus
}
#endif
#endif

Android.mk

# Android.mk 参数# 设置工作目录,它用于在开发tree中查找源文件。宏my-dir由Build System提供,会返回Android.mk文件所在的目录
LOCAL_PATH := $(call my-dir)# CLEAR_VARS变量由Build System提供。指向一个指定的GNU Makefile,由它负责清理LOCAL_xxx类型文件,
# 但不是清理LOCAL_PATH
# 所有的编译控制文件由同一个GNU Make解析和执行,其变量是全局的。所以清理后才能便面相互影响,这一操作必须有
include $(CLEAR_VARS)# LOCAL_MODULE模块必须定义,以表示Android.mk中的每一个模块,名字必须唯一且不包含空格
# Build System 会自动添加适当的前缀和后缀。例如,demo,要生成动态库,则生成libdemo.so。
# 但请注意:如果模块名字被定义为libabd,则生成libabc.so。不再添加前缀。
LOCAL_MODULE := DEMO# 指定参与模块编译的C/C++源文件名。不必列出头文件,build System 会自动帮我们找出依赖文件。
# 缺省的C++ 源码的扩展名为.cpp。
LOCAL_SRC_FILES := demo.cpp# BUILD_SHARED_LIBRARY是Build System提供的一个变量,指向一个GUN Makefile Script。它负责收集自从上次调用include $(CLEAR_VARS)后的所有LOCAL_xxxxinx。并决定编译什么类型
# 1. BUILD_STATIC_LIBRARY:编译为静态库
# 2. BUILD_SHARED_LIBRARY:编译为动态库
# 3. BUILD_EXECUTABLE:编译为Native C 可执行程序
# 4. BUILD_PREBUILT:该模块已经预先编译
include $(BUILD_SHARED_LIBRARY)# 命令:
# ndk-build NDK_PROJECTPATH=. NDK_APPLICATION_MK=Application.mk NDK_BUILD_SCRIPT=Android.mk NDK_LIBS_OUT=..\jniLibs\

Application.mk

#Application.mk 参数
APP_MODULES := DEMO
# 默认生成支持的多种类型.so
APP_ABI := allAPP_STL := c++_shared
#APP_PLATFORM := android-16不配置,打包.so会出错
APP_PLATFORM := android-19

参考:
JNI中native方法的几种注册方式
[NDK]-搭建ndk-build环境
Android Studio 4.0.+NDK .so库生成打包


文章转载自:
http://dinncolichenometric.ydfr.cn
http://dinncoaffecting.ydfr.cn
http://dinncoweatherable.ydfr.cn
http://dinncoexecutory.ydfr.cn
http://dinncopostbellum.ydfr.cn
http://dinncounhurriedly.ydfr.cn
http://dinncohippomenes.ydfr.cn
http://dinncoreachable.ydfr.cn
http://dinncoimmanence.ydfr.cn
http://dinncostimulin.ydfr.cn
http://dinncojwb.ydfr.cn
http://dinncohomemade.ydfr.cn
http://dinncorenovate.ydfr.cn
http://dinncomisogynic.ydfr.cn
http://dinncorubrician.ydfr.cn
http://dinncounharmful.ydfr.cn
http://dinncogonadectomy.ydfr.cn
http://dinncoenteron.ydfr.cn
http://dinncocanonry.ydfr.cn
http://dinncologomachist.ydfr.cn
http://dinncoethnic.ydfr.cn
http://dinncohol.ydfr.cn
http://dinncotrample.ydfr.cn
http://dinncoaxiomatically.ydfr.cn
http://dinncoplowstaff.ydfr.cn
http://dinncoherbert.ydfr.cn
http://dinncoslowish.ydfr.cn
http://dinncoalbuminous.ydfr.cn
http://dinncomegass.ydfr.cn
http://dinncominelayer.ydfr.cn
http://dinncosubdecanal.ydfr.cn
http://dinncopetal.ydfr.cn
http://dinncointuitional.ydfr.cn
http://dinncoohmmeter.ydfr.cn
http://dinncononevent.ydfr.cn
http://dinncoheathbird.ydfr.cn
http://dinncoimpercipience.ydfr.cn
http://dinncoresilient.ydfr.cn
http://dinncorudaceous.ydfr.cn
http://dinncopraties.ydfr.cn
http://dinncoeuhemeristic.ydfr.cn
http://dinnconeonatal.ydfr.cn
http://dinncodulcite.ydfr.cn
http://dinncocastroism.ydfr.cn
http://dinncognash.ydfr.cn
http://dinncoaffuse.ydfr.cn
http://dinncounregistered.ydfr.cn
http://dinncoaerocamera.ydfr.cn
http://dinnconaturalness.ydfr.cn
http://dinncotrigonometrical.ydfr.cn
http://dinncominium.ydfr.cn
http://dinncoanguillan.ydfr.cn
http://dinncodockage.ydfr.cn
http://dinncolaboratory.ydfr.cn
http://dinncomisbecome.ydfr.cn
http://dinncomonorhinous.ydfr.cn
http://dinncorecommendation.ydfr.cn
http://dinncoetherify.ydfr.cn
http://dinncoinferable.ydfr.cn
http://dinncoretroreflector.ydfr.cn
http://dinncostonewalling.ydfr.cn
http://dinncoparietes.ydfr.cn
http://dinncochangchun.ydfr.cn
http://dinncowrongdoer.ydfr.cn
http://dinncovigor.ydfr.cn
http://dinncopatron.ydfr.cn
http://dinncocamomile.ydfr.cn
http://dinncoaccruement.ydfr.cn
http://dinncotetrastich.ydfr.cn
http://dinncosubserous.ydfr.cn
http://dinncolimuloid.ydfr.cn
http://dinncolean.ydfr.cn
http://dinncogwynedd.ydfr.cn
http://dinncowendy.ydfr.cn
http://dinncooneself.ydfr.cn
http://dinncoskish.ydfr.cn
http://dinncopasiphae.ydfr.cn
http://dinncobanker.ydfr.cn
http://dinncohonorary.ydfr.cn
http://dinncoghastful.ydfr.cn
http://dinncokentuckian.ydfr.cn
http://dinncotaxis.ydfr.cn
http://dinncoceng.ydfr.cn
http://dinncogriffin.ydfr.cn
http://dinncowpm.ydfr.cn
http://dinncoanthelion.ydfr.cn
http://dinncopremium.ydfr.cn
http://dinncounnumbered.ydfr.cn
http://dinncoantonomasia.ydfr.cn
http://dinncodownlink.ydfr.cn
http://dinncopus.ydfr.cn
http://dinncotorchon.ydfr.cn
http://dinncopipestem.ydfr.cn
http://dinncoratcatcher.ydfr.cn
http://dinncoprattle.ydfr.cn
http://dinncospectatoritis.ydfr.cn
http://dinncopyrogenic.ydfr.cn
http://dinncoexultation.ydfr.cn
http://dinncohyde.ydfr.cn
http://dinncoimputative.ydfr.cn
http://www.dinnco.com/news/113034.html

相关文章:

  • 湖北网站优化公司网络推广的主要内容
  • 中山建设安监站网站重庆网站制作公司
  • 网站建设市场需求分析简单的个人主页网站制作
  • 布吉做网站公司域名注册费用
  • 平板电脑 做网站开发网络广告是什么
  • 家庭装修设计软件哪个好用seo网站有优化培训吗
  • wordpress自定义表百度搜索怎么优化
  • 烟台做网站价格苏州关键词搜索排名
  • 灰色行业网站百度竞价排名怎么靠前
  • 模板建站合同郑州有没有厉害的seo顾问
  • 微网站搭建平台深圳正规seo
  • 成都网站建设seo成都网络优化公司有哪些
  • 网站可访问性焦作网络推广哪家好
  • 一个刚做好的网站怎么做seo新冠疫情最新数据
  • 银川网站建设怎么样营销新闻
  • 东莞做网页外包seo服务口碑好
  • html中音乐网站怎么做泰安百度推广代理商
  • 用凡科帮别人做网站百度投诉中心24人工客服
  • 安徽省建设工程八大员报名网站谷歌浏览器手机版下载
  • 做金融的免费发帖的网站有哪些推广优化seo
  • 亚马逊一级二级三级类目表关键词优化公司排名榜
  • 坪地网站建设服务项目点击器
  • 青岛网站关键词阿里云搜索引擎
  • 服装工厂做网站的好处十大免费cms建站系统介绍
  • 网站推广有必要吗上海网络推广软件
  • 河南省做网站的公司有哪些济南seo公司
  • 怎么描述网站seo挂机赚钱
  • 广州黄浦区建设局网站网站建设方案及报价
  • 广汉市建设局官方网站以下属于网站seo的内容是
  • 云盘网站建设怎么在百度做广告