- 创建一个native c++项目
- 把OpenBLAS源码拷贝到src\main\cpp\OpenBLAS-0.3.10
- 修改 src\main\cpp\CMakeLists.txt,包含源码CMakeLists
cmake_minimum_required(VERSION 3.10.0)
add_subdirectory(OpenBLAS-0.3.10)
- 修改 app/build.gradle ,根据自己需要修改配置
externalNativeBuild {
cmake {
cppFlags "-std=c++11"
arguments "-DTARGET = ARMV7",
"-DBINARY = 32",
"-DONLY_CBLAS = 1", //仅需要CBLAS
"-DARM_SOFTFP_ABI=1",
"-DUSE_THREAD = 0" //单线程,减少内存占用
}
}
ndk {
abiFilters 'armeabi-v7a'
}
- 修改 src\main\cpp\OpenBLAS-0.3.10\CMakeLists.txt
//g0删掉调试信息,减少库尺寸
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g0")