標籤:android tar get int http 檔案
標準的做法是 把 src 放到 /Android/develop/ 目錄下去,然後建立 Android.mk 檔案,
然後 make modue ...., 但是,這種方式 太麻煩。
下面介紹一種方法,可以比較快速的編譯 C 庫,
和上一篇中一樣,首先要設定自己的環境變數:
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/
然後依然是建立一個 mk 檔案:
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
然後是你自己的 lib 的 makefile.
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 [email protected] finished on `date`"
clean:
@rm -f $(TARGET_OUTPUT)
@rm -rf obj
然後 make 就可以了。
編譯出來的庫貌似需要放到 /system/lib 下去。
本篇文章來源於 Linux公社網站(www.linuxidc.com) 原文連結:http://www.linuxidc.com/Linux/2010-08/27880p3.htm