Android JNI学习-使用第三方SO库
https://david1840.github.io/2018/12/03/Android-JNI学习-使用第三方SO库/
CMakeList.txt
在CMake中将LibTest.so导入工程
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
UseSo
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/jni/UseSo.c )
#导入第三方so包,并声明为 IMPORTED 属性,指明只是想把 so 导入到项目中
add_library( Test
SHARED
IMPORTED )
#指明 so 库的路径,CMAKE_SOURCE_DIR 表示 CMakeLists.txt 的路径
set_target_properties(
Test
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/jniLibs/armeabi-v7a/libTest.so )
#指明头文件路径,不然会提示找不到 so 的方法
include_directories(src/main/jni/)
find_library(log-lib
log )
target_link_libraries( # Specifies the target library.
UseSo
Test
${log-lib} )
build.gradle
ndk {
abiFilters 'armeabi-v7a'
}
本文来自博客园,作者:源世,转载请注明原文链接:https://www.cnblogs.com/jsxzhub/p/18084813
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述