1、下载安装并配置NDK环境
如已有该环境,跳过。
国内推荐在此下载:
2、下载
OpenBLAS
并解压
编译可参看
我用的是OpenBLAS-0.2.20
3、
编译Openblas
1)打开终端
设置环境变量:
export PATH=/home/xx/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH
2)修正ndk路径
在以下文件中
OpenBLAS-0.2.20/
interface/
Makefile
OpenBLAS-0.2.20/driver/level2/
Makefile
OpenBLAS-0.2.20/driver/level3/
Makefile
OpenBLAS-0.2.20/driver/
others/
Makefile
OpenBLAS-0.2.20/
kernel/
Makefile
加入:
override CFLAGS += -I/home/xx/android-ndk-r14b/platforms/android-19/arch-arm/usr/include -I.
3)此时编译的话会遇到以下错误
/home/xx/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: 没有那个文件或目录
/home/xx/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: 没有那个文件或目录
/home/xx/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: 没有那个文件或目录
/home/xx/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: 没有那个文件或目录
collect2: error: ld returned 1 exit status
Makefile:140: recipe for target '../libopenblas_armv7p-r0.2.20.so' failed
make[1]: *** [../libopenblas_armv7p-r0.2.20.so] Error 1
make[1]: Leaving directory '/home/acrfid/can/OpenBLAS-0.2.20/exports'
Makefile:90: recipe for target 'shared' failed
make: *** [shared] Error 2
解决方式:
进入OpenBLAS-0.2.20/exports目录,输入以下指令:
ln -snf /home/xx/android-ndk-r14b/platforms/android-19/arch-arm/usr/lib/crtbegin_so.o ./
ln -snf /home/xx/android-ndk-r14b/platforms/android-19/arch-arm/usr/lib/crtend_so.o ./
ln -snf /home/xx/android-ndk-r14b/platforms/android-19/arch-arm/usr/lib/crtbegin_dynamic.o ./
ln -snf /homexx/android-ndk-r14b/platforms/android-19/arch-arm/usr/lib/crtend_android.o ./
4)编译
进入OpenBLAS-0.2.20目录,输入以下指令:
make TARGET=ARMV7 ARM_SOFTFP_ABI=1 HOSTCC=gcc CC=arm-linux-androideabi-gcc NOFORTRAN=1
成功后:
OpenBLAS build complete. (BLAS CBLAS)
OS ... Android
Architecture ... arm
BINARY ... 32bit
C compiler ... GCC (command line : arm-linux-androideabi-gcc)
Library Name ... libopenblas_armv7p-r0.2.20.a (Multi threaded; Max num-threads is 4)
To install the library, you can run "make PREFIX=/path/to/your/installation install".
安装
make PREFIX=/home/xx/OpenBLAS-0.2.20/install install