The standard practice is to put SRC into the/android/develop/directory and then build the Android.mk file,
Then make modue ..., but this way is too cumbersome.
Here's a way to quickly compile C libraries,
As in the previous article, you first set up your own environment variables:
Cat setenv.sh
Export path= $PATH:/android/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin
Export Cross_compiler=arm-eabi
Export Target=1
Export anddroid=1
Export A=/android/mydroid/
Then still build a Mk file:
Cat Zconfiglib.mk
ifdef anddroid
abionic=$ (a) bionic/libc/
aoutlib=$ (a) out/target/product/teton_ebook/obj/lib/
CFLAGS + =-I $ (a) Bionic/libc/arch-arm/include-i $ (a) Bionic/libc/include-i $ (a) Bionic/libc/kernel/common-i $ (a) bionic /libc/kernel/arch-arm-c-fno-exceptions-wno-multichar-march=armv5te-mtune=xscale-msoft-float-fpic- Mthumb-interwork-ffunction-sections-funwind-tables \
-fstack-protector-d__arm_arch_5__-D__ARM_ARCH_5T_ _-d__arm_arch_5e__-d__arm_arch_5te__ \
-include $ (A) System/core/include/arch/linux-arm/androidconfig.h- Dandroid-fmessage-length=0-w-wall-wno-unused-dsk_release-dndebug \
-o2-wstrict-aliasing=2- Finline-functions-fno-inline-functions-called-once-fgcse-after-reload-frerun-cse-after-loop \
- frename-registers-dndebug-udebug-mthumb-os-fomit-frame-pointer-fno-strict-aliasing-finline-limit=64 -MD
LIBS + =-nostdlib-wl,-soname,-wl,-t,$ (A) build/core/armelf.xsc-wl,--gc-sections-wl,-bsymbolic-l$ (AoutLib)-Wl,-- WHOLE-ARCHIVE-WL,--no-whole-archive-lc-lm-wl,--no-undefined $ (A)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/ bin/. /lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a
Then the makefile of your own lib.
Cat Makefile
Ifdef TARGET
Include/zconfiglib.mk
cross=$ (Cross_compiler)-
cc=$ (Cross) GCC
ar=$ (Cross) AR
ld=$ (Cross) LD
Else
CC = gcc
AR = AR
LD = LD
STRIP = STRIP
endif
include+=-I.. /-i./
libs+=-shared
Obj_dir = obj/
OBJECTS = $ (obj_dir) hello.o
Target_output=./libhello
CFLAGS + =
All: $ (target_output) $ (test_output) $ (OBJECTS)
$ (Obj_dir)%.O:%.c
@-mkdir-p $ (Obj_dir)
$ (CC) $ (INCLUDE) $ (CFLAGS)-C $<-o [email protected]
$ (Target_output): $ (OBJECTS)
$ (CC) $ (LIBS)-O $ (target_output) $ (OBJECTS) $ (Ld_path)
@echo "Make [e-mail protected] finished on ' Date '"
Clean
@rm-F $ (target_output)
@rm-rf obj
and make it.
The compiled library looks like it needs to be put down to/system/lib.
This article is from the Linux commune website (www.linuxidc.com) Source Link: http://www.linuxidc.com/Linux/2010-08/27880p3.htm