参考

https://www.cnblogs.com/hrlnw/p/4128217.html

1.从https://github.com/simonlynen/android_libs这个网址下载代码。

如何在android上进行android库编译

https://blog.csdn.net/h3c4lenovo/article/details/10364679

1 设置ndk环境
export ANDROID_NDK_HOME=/DATA/Android/Ndk/android-ndk-r13b
export PATH=$PATH:$ANDROID_NDK_HOME
#ANDROID_NDK_HOME=/DATA/share/software/android-ndk-r16

2 make 与gcc确保无问题
make -v
gcc -v

3 写好jni文件

4 编译ndk-build

5 android工程调用

#如果同时编译32和64未版本,或会导致32位的库打包到64位中,需要单独编译,
#./obj/local/arm64-v8a/libtestlapack.so: error adding symbols: File in wrong format

导致32位的库打包到64位中,
[arm64-v8a] Prebuilt : libtestlapack.so <= jni/lapack/lib/armeabi-v7a/
[arm64-v8a] Install : libtestlapack.so => libs/arm64-v8a/libtestlapack.so
[arm64-v8a] Compile++ : mtcnn_facedetect <= similaritytrans.cpp

#include <stdio.h>
#include <string.h>
#include <jni.h>
#include <complex>
#include <sstream>
#include <string>
#include <android/log.h>
#define TAG "log"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__) // #ifndef JNIEXPORT
// #define JNIEXPORT
// #endif // #ifndef JNICALL
// #define JNICALL
// #endif static long dgesvd(char *jobu, char *jobvt, long *m, long *n,
double *a, long *lda, double *s, double *u, long *
ldu, double *vt, long *ldvt, double *work, long *lwork)
{
// int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n,
// doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
// ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
// integer *info) extern int dgesvd_(char *jobu, char *jobvt, long *m, long *n,
double *a, long *lda, double *s, double *u, long *
ldu, double *vt, long *ldvt, double *work, long *lwork,
long *info); long info;
dgesvd_("A", "A", m, n, a, lda, s, u, ldu, vt, ldvt, work, lwork, &info);
return info;
} #define mymax(a,b) (a) > (b) ? (a) : (b)
#define mymin(a,b) (a) < (b) ? (a) : (b) void transposeMatrix(double *A, int row, int col)
{
for(int i =; i < row; ++i)
{
for (int j = i; j < col; ++j)
{
double temp = A[i * col + j];
A[i * col + j] = A[j * col + i];
A[j *col + i] = temp;
}
}
} int GetLapackSVD(double *a, double *u, double *s, double *vt)
{
//double a[2*2] = {4 , 4 , -3 , 3};
//这个函数,这里要特别注意储存方式(column major)!!
transposeMatrix(a,,);
long m,n;
long lda,ldu,ldvt,lwork;
m = ;
n = ;
lda = ;
ldu = ;
ldvt = ;
//https://blog.csdn.net/versuna/article/details/8246377
lwork = ;//mymax(3*mymin(m, n)+mymax(m, n), 5*mymin(m,n));
LOGD("#lwork = %d", lwork);
double work[*lwork];
char jobu = 'A';
char jobvt = 'A';
dgesvd(&jobu, &jobvt, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork);
return ;
} int main()
{
double a[];
double u[];
double s[];
double vt[];
}

在贴一段内部代码

/*****************************************************************************
Copyright (c) 2014, Intel Corp.
All rights reserved. Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************
* Contents: Native high-level C interface to LAPACK function dgesdd
* Author: Intel Corporation
* Generated November 2015
*****************************************************************************/ #include "lapacke_utils.h" lapack_int LAPACKE_dgesdd( int matrix_layout, char jobz, lapack_int m,
lapack_int n, double* a, lapack_int lda, double* s,
double* u, lapack_int ldu, double* vt,
lapack_int ldvt )
{
lapack_int info = ;
lapack_int lwork = -;
lapack_int* iwork = NULL;
double* work = NULL;
double work_query;
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
LAPACKE_xerbla( "LAPACKE_dgesdd", - );
return -;
}
#ifndef LAPACK_DISABLE_NAN_CHECK
if( LAPACKE_get_nancheck() ) {
/* Optionally check input matrices for NaNs */
if( LAPACKE_dge_nancheck( matrix_layout, m, n, a, lda ) ) {
return -;
}
}
#endif
/* Allocate memory for working array(s) */
iwork = (lapack_int*)
LAPACKE_malloc( sizeof(lapack_int) * MAX(,*MIN(m,n)) );
if( iwork == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
/* Query optimal working array(s) size */
info = LAPACKE_dgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
ldvt, &work_query, lwork, iwork );
if( info != ) {
goto exit_level_1;
}
lwork = (lapack_int)work_query;
/* Allocate memory for work arrays */
work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
if( work == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_1;
}
/* Call middle-level interface */
info = LAPACKE_dgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
ldvt, work, lwork, iwork );
/* Release memory and exit */
LAPACKE_free( work );
exit_level_1:
LAPACKE_free( iwork );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_dgesdd", info );
}
return info;
}

clapack在android上移植的更多相关文章

  1. 将 Android 应用移植到 BlackBerry PlayBook 上

    美国西部时间18号早上,也就是我们的19号凌晨,BlackBerry DevCon活动隆重举行,PlayBook 2.0开发测试版随之发布.PlayBook 2.0的一个重要功能就是支持Android ...

  2. FFmpeg在Android上的移植之第一步

    http://blog.sina.com.cn/s/blog_69a04cf40100x1fr.html 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmpeg开发的. ...

  3. Android系统移植(一)-让android系统在目标平台上运行起来

    编号),文件系统采用ubifs格式,控制台设备为ttyS1,波特率为115200 启动的第一个应用程序是/init (6)确保控制台的设置和硬件保持一致,如:硬件上串口用的是UART1,则内核启动参数 ...

  4. FFmpeg在Android上的移植优化步骤

    http://blog.csdn.net/feixiang_john/article/details/7894188 从事多媒体软件开发的人几乎没有不知道FFmpeg的,很多视频播放器都是基于FFmp ...

  5. 系列篇|编译可在Android上运行的依赖库(一):glib库

    前言 这是系列文章,它们由<编译可在Android上运行的glib库>及其他4篇文章组成,这4篇文章在“编译依赖库”一节中列出.由于glib库依赖于其他第三方库,所以需要先将依赖的第三方库 ...

  6. 第一章 Android系统移植与驱动开发概述

    本书第一章首先简单概要地介绍了关于Android系统移植和驱动开发的相关内容. 所谓“移植”是指为特定的自己的设备,如手机定制Android的过程.自己开发一些程序(移植)装载在设备上,使得Andro ...

  7. 浅谈Android系统移植、Linux设备驱动

    一.Android系统架构 第一层:Linux内核 包括驱动程序,管理内存.进程.电源等资源的程序 第二层:C/C++代码库 包括Linux的.so文件以及嵌入到APK程序中的NDK代码 第三层:An ...

  8. 第一章Android系统移植与驱动开发概述--读书笔记

    以前,初步学习过嵌入式Linux驱动开发的基础课程,对于驱动开发可以说是有了一点点微末的基础吧.首先我们要对Android嵌入式系统有一个初步的认识,Android系统发展到今天已经具备了完善的架构. ...

  9. Android深度探索HAL和驱动开发(卷1) 第一章 Android系统移植和驱动开发

    由于Android是基于Linux内核的,因此,Android和其他Linux系统的核心部分差异非常小.然而不同版本的Android使用的Linux内核的版本有细微的差异,所以不同Android驱动可 ...

随机推荐

  1. 每日英语:China's Wistful Wen Gets His Wish

    As his term as premier was drawing to a close, Wen Jiabao reflected wistfully on some of the goals h ...

  2. raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found 解决办法

    报错信息如下: Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a5/e9/51b544da85a36a68debe7a7091f068d ...

  3. VirtualBox与VMWare网络冲突

    VirtualBox安装一个XP后,发现老是上不到网,怎么折腾都不行, 后来发现设备管理器中 vmware accelerated amd pcnet adapter #2显示黄色感叹号 不对呀,这是 ...

  4. 分布式系统唯一ID生成方案汇总【转】

    转自:http://www.cnblogs.com/haoxinyue/p/5208136.html 系统唯一ID是我们在设计一个系统的时候常常会遇见的问题,也常常为这个问题而纠结.生成ID的方法有很 ...

  5. js 将数字转换成人民币大写的方法

    //将数字转换成人民币大写的方法 var digitUppercase = function (n) { var fraction = ['角', '分']; var digit = [ '零', ' ...

  6. vi/vim使用进阶: 文件浏览和缓冲区浏览

    原文:https://blog.easwy.com/archives/advanced-vim-skills-netrw-bufexplorer-winmanager-plugin/ 本节所用命令的帮 ...

  7. Android开发(三)——Android布局中实现圆角边框

    设置corners_bg.xml(设置边框圆角可以在drawable-mdpi目录里定义一个xml): <?xml version="1.0" encoding=" ...

  8. postgre与mysql区别

    SQL兼容性 PostgreSQL 9.5 兼容 SQL:2011 子集 http://www.postgresql.org/docs/9.5/static/features-sql-standard ...

  9. 固定高度div,随内容自动变高css定义方法

    *{ font-size:12px; margin:0; padding:0;}方法1:#testBox{border:1px solid #cccccc;padding:5px;width:220p ...

  10. php implode

    implode() 函数返回由数组元素组合成的字符串. <?php $arr = array('Hello','World!','I','love','Shanghai!'); echo imp ...