Android下openssl编译和使用(二)

2019-08-30 21:59:20

接下来我们看看如何使用


1、新建一个测试工程,并勾选include C++ support


2、把openssl-1.1.1b/include下的openssl目录,整个复制到项目src下的cpp子目录


3、把lib下的libcryto.a和libssl.a复制到src/cpp/libs子目录




4、修改CMakeList.txt文件,在cmake_minimum_required(VERSION 3.4.1)后面添加:


#表示把src/main/cpp加入到include目录,这样在代码中使用:#include <...>就能访问到头文件

include_directories(src/main/cpp)

 

#添加两个预编译库

add_library(# Sets the name of the library.

        openssl-crypto

        # Sets the library as a static library.

        STATIC

        IMPORTED)

 

set_target_properties(

        # Specifies the target library.

        openssl-crypto

        # Specifies the parameter you want to define.

        PROPERTIES IMPORTED_LOCATION

        # Provides the path to the library you want to import.

        ${CMAKE_SOURCE_DIR}/src/main/cpp/libs/${ANDROID_ABI}/libcrypto.a)

 

add_library(# Sets the name of the library.

        openssl-ssl

        # Sets the library as a static library.

        STATIC

        IMPORTED)

 

set_target_properties(

        # Specifies the target library.

        openssl-ssl

        # Specifies the parameter you want to define.

        PROPERTIES IMPORTED_LOCATION

        # Provides the path to the library you want to import.

        ${CMAKE_SOURCE_DIR}/src/main/cpp/libs/${ANDROID_ABI}/libssl.a)

5、修改CMakeList.txt文件最后的target_link_libraries如下:


target_link_libraries( # Specifies the target library.

        native-lib

 

        # Links the target library to the log library

        # included in the NDK.

        ${log-lib} openssl-ssl openssl-crypto)

6、修改native-lib.cpp返回openssl版本信息




7、启动app可以看到如下显示结果:




  • 2019-12-29 15:01:37

    修改laravel分页的样式

    首先获取到数据,paginate方法 能够自动判定当前页面正确的数量限制和偏移数。默认情况下,当前页数由HTTP 请求所带的 ?page 参数来决定。当然,该值由 Laravel 自动检测,并自动插入由分页器生成的链接。

  • 2019-12-29 15:05:57

    php 数组分页 array_slice()函数用法

    今天用到一个函数,非常好用,分享给大家 array_slice() -从数组中取出一段 也就是说用这个函数可以和sql语句一样实现分页,原理是将查询出的数组,取出从指定下标开始到指定长度的数组

  • 2019-12-30 10:17:21

    router-link传递参数,query

    在vue-router中,有两大对象被挂载到了实例this; $route(只读、具备信息的对象); $router(具备功能的函数) 查询字符串: 去哪里 ? <router-link :to="{name:'detail',query:{id:1}}"> xxx </router-link>

  • 2019-12-30 16:48:41

    vue provide/inject详解和用法

    父子组件交互方式多种,props、vuex、 、 emit、localStorage还有就是这个provide/inject了。它适合层级比较深的组件,比如子,子孙,子孙后代的组件有好几个用到父组件的某个属性,就可以用到这个provide/inject,它可以避免写大量繁琐的传值代码 我这里为什么要使用它? 我一个知识库详情父组件中包含了大量的子组件,每个子组件都需要父组件的知识库ID,这时候我不想写大量props,就用到provide/inject进行传值了