• Openblas编译Android NDK库的步骤


    1、配置Android NDK编译工具。
    以下下载地址,直接放到浏览器中下载,不需要VPN
    linux 32 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86.bin
    linux 64 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin

    Windows 32 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86.exe
    64 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-windows-x86_64.exe

    Mac OS X 32 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86.bin
    64 bit
    http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86_64.bin
    安装方法:
    请确保你已安装了Android SDK
    Linux 与Mac OS X (Darwin):
    打开终端,进入到你下载包所在的目录
    执行chmod a+x 下载包名, 使其可执行,然后执行安装包就行
    比如:
    ndk$ chmod a+x android-ndk-r10c-darwin-x86_64.bin
    ndk$ ./android-ndk-r10c-darwin-x86_64.bin

    windows安装相对容易,直接双击安装包

    假设解压出来的目录在/usr/local/android-ndk-r10下

    配置环境变量:
    export NDK=/usr/local/android-ndk-r10
    export PATH=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin:$PATH


    2、下载Openblas源代码:
    下载路径:https://sourceforge.net/projects/openblas/files/

    下载源代码版本:openblas_0.2.18.orig.tar.gz 和 openblas_0.2.18-1.dsc

    将压缩代码文件解压到目标路径。

    3、编译Openblas的Android库文件。
    编译指导:
    https://github.com/xianyi/OpenBLAS/wiki/How-to-build-OpenBLAS-for-Android


    a. 打开终端

    b. 设置环境变量:
    export SYSROOT=$NDK/platforms/android-19/arch-arm
    export CC="$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT"

    c. 执行编译命令:
    make TARGET=ARMV7 HOSTCC=gcc CC=arm-linux-androideabi-gcc NOFORTRAN=1


    d. 编译问题:
    sys/cdefs.h头文件找不到问题。
    In file included from getarch.c:80:0:
    /usr/local/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.8/include-fixed/stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
    #include <sys/cdefs.h>


    DIT re: the latest question revision:
    The real question is - why is the compiler looking for header files under toolchainsarm-linux-androideabi-4.6prebuiltwindowslibgccarm-linux-androideabi4.6.x-googleinclude-fixed, when they are really at platformsandroid-9arch-armusrinclude? Is there a rogue -I option somewhere? The include folder under toolchains, that the OP is having trouble with, looks crippled; it's probably an artifact of the GCC distribution. The real NDK header folder is elsewhere.

    e. 修改文件路径:
    interfaceMakefile
    driverlevel2Makefile
    driverlevel3Makefile
    driverothersMakefile
    kernelMakefile

    f. 修改内容:
    override CFLAGS += -I/usr/local/android-ndk-r10/platforms/android-19/arch-arm/usr/include -I.

    g. 继续执行编译
    make TARGET=ARMV7 HOSTCC=gcc CC=arm-linux-androideabi-gcc NOFORTRAN=1

    h. 执行完成,打包库。
    OpenBLAS build complete. (BLAS CBLAS)

    OS ... Android
    Architecture ... arm
    BINARY ... 32bit
    C compiler ... GCC (command line : arm-linux-androideabi-gcc)
    Library Name ... libopenblas_armv7-r0.2.18.a (Single threaded)

    To install the library, you can run "make PREFIX=/path/to/your/installation install".

    执行命令打包库文件。
    make PREFIX=/home/zoufeng/openblas install

  • 相关阅读:
    UVA 11488 Hyper Prefix Sets (字典树)
    UVALive 3295 Counting Triangles
    POJ 2752 Seek the Name, Seek the Fame (KMP)
    UVA 11584 Partitioning by Palindromes (字符串区间dp)
    UVA 11100 The Trip, 2007 (贪心)
    JXNU暑期选拔赛
    计蒜客---N的-2进制表示
    计蒜客---线段的总长
    计蒜客---最大质因数
    JustOj 2009: P1016 (dp)
  • 原文地址:https://www.cnblogs.com/zoufeng/p/5798013.html
Copyright © 2020-2023  润新知