linux ndk-build 编译.so 将底层c程序编译为so文件
1.ndk下载:https://developer.android.google.cn/ndk/downloads/
2.ndk安装:https://blog.csdn.net/fanx9339/article/details/81116332
3.编译 .so:https://blog.csdn.net/ylq777/article/details/94574492
4.ndk学习资源:https://developer.android.google.cn/ndk/guides
通过linux将c编译为so文件:
1.虚拟机如果已经安装vmWare Tool,则直接将在Windows上写好的c源码拖入虚拟机,这里我使用的是通过共享文件放进虚拟机中,使用ndk需要将源码放入jni文件夹,并创建Android.mk和Application.mk文件,否则无法使用ndk
2.放入虚拟机过程
# cd /home/jgxie
# ls
Android Downloads Music Public umsJNI
Desktop examples.desktop ndk-umis_trans Templates Videos
Documents mbuntu-linuxidc.com.jpg Pictures umis
# rm -rf ndk-umis_trans
# cp -r /mnt/hgfs/gongxiang/ndk-umis_trans /home/jgxie
# ls
Android Downloads Music Public umsJNI
Desktop examples.desktop ndk-umis_trans Templates Videos
Documents mbuntu-linuxidc.com.jpg Pictures umis
3.使用ndk编译过程
# cd ndk-umis_trans
# ls
changeLog.txt include jni print.txt pubIP.txt SP30POS.INI src trans.rcd
# cd jni
# ls
Android.mk Application.mk include src test
# ndk-build
[armeabi-v7a] Compile thumb : umis <= dbg.c
/home/jgxie/ndk-umis_trans/jni/src/dbg.c:83:14: warning: 'debug_progname_on' defined but not used [-Wunused-function]
[armeabi-v7a] Compile thumb : umis <= err.c
[armeabi-v7a] Compile thumb : umis <= inifile.c
[armeabi-v7a] Compile thumb : umis <= log.c
[armeabi-v7a] Compile thumb : umis <= profunc.c
.
.
.
[mips] Compile : umis <= t_sprintf.c
[mips] SharedLibrary : libumis.so
[mips] Install : libumis.so => libs/mips/libumis.so
4.将要使用的so文件拿到共享文件夹
# cd ..
# ls
changeLog.txt jni obj pubIP.txt src
include libs print.txt SP30POS.INI trans.rcd
# cd libs/armeabi-v7a
# ls
libumis.so
# cp libumis.so /mnt/hgfs/gongxiang/
这篇博客主要用于记录操作过程,较菜,大佬勿喷,谢谢。