Android NDK中编译Openblas库

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值