关于android源码包下makefile编译以及使用STL库相关问题
作者:互联网
以下是android源码中使用makefile编译文件
APP=main NDK_DIR := /home/xxx #NDK_HOST := linux-x86 ANDROID_PATH = /home/xxx/ SDKTOOL := /opt/android-sdk/tools TOOLCHAIN_PREFIX := $(NDK_DIR)/arm-eabi-4.4.3/bin/arm-eabi- CC := $(TOOLCHAIN_PREFIX)gcc CPP := $(TOOLCHAIN_PREFIX)g++ LD := $(CC) COMMON_FLAGS := -mandroid -ffunction-sections -fdata-sections -Os -g --sysroot=$(NDK_DIR)/android-8/arch-arm -fPIC -fvisibility=hidden -D__NEW__ CFLAGS := $(COMMON_FLAGS) CFLAGS =-I$(ANDROID_PATH)/usr/include CFLAGS += -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG CFLAGS += -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -ffunction-sections -funwind-tables -fstack-protector -fmessage-length=0 -Bdynamic CPPFLAGS := $(COMMON_FLAGS) -fno-rtti -fno-exceptions -fvisibility-inlines-hidden LDFLAGS += --sysroot=$(NDK_DIR)/android-8/arch-arm LDFLAGS += -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc LDFLAGS += -L$(NDK_DIR)/arm-eabi-4.4.3/lib/gcc/arm-eabi/4.4.3 LDFLAGS += -L$(NDK_DIR)/arm-eabi-4.4.3/lib/gcc LDFLAGS += -L$(NDK_DIR)/arm-eabi-4.4.3/arm-eabi/lib LDFLAGS += -L$(NDK_DIR)/android-8/arch-arm/lib LDFLAGS += $(NDK_DIR)/桌面/test/libtest/libtest.o LDFLAGS += $(NDK_DIR)/桌面/test/libtest/libtesta.o LDFLAGS += -nostdlib -lc -llog -lgcc --no-undefined $(NDK_DIR)/android-8/arch-arm/usr/lib/crtbegin_dynamic.o $(NDK_DIR)/android-8/arch-arm/usr/lib/crtend_android.o OBJS += $(APP).o all: $(APP) $(APP): $(OBJS) $(LD) $(LDFLAGS) -o $@ $^ %.o: %.c $(CC) -c $(CFLAGS) $< -o $@ %.o: %.cpp $(CPP) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ clean: @rm -f $(APP).o $(APP)
ANDROID_PATH = /home/xxx/
TOOLCHAIN_PATH =$(ANDROID_PATH)/arm-eabi-4.4.3/bin
COMMON_FLAGS := -mandroid -ffunction-sections -fdata-sections -Os -g
--sysroot=$(NDK_DIR)/android-8/arch-arm -fPIC
-fvisibility=hidden -D__NEW__
CFLAGS := $(COMMON_FLAGS)
CPPFLAGS := $(COMMON_FLAGS) -fno-rtti -fno-exceptions -fvisibility-inlines-hidden
CFLAGS =-I$(ANDROID_PATH)/usr/include
LDFLAGS =-L$(ANDROID_PATH)/usr/lib
CC = $(TOOLCHAIN_PATH)/arm-eabi-gcc
LD = $(TOOLCHAIN_PATH)/arm-eabi-ld
CPP := $(TOOLCHAIN_PATH)/arm-eabi-g++
EXTRA_OBJS = $(LDFLAGS)/crtbegin_dynamic.o $(LDFLAGS)/crtend_android.o
all:
$(CPP) -O2 -fPIC -c $(CFLAGS)$(CPPFLAGS) $(LDFLAGS) libtesta.cpp -o libtesta.o
$(LD) -o libtesta.so libtesta.o -shared
clean:
rm -rf libtesta.o
rm -rf libtesta.so
NDK JNI下注意Applicantion.mk关于STL库部分
APP_MODULES :=hello-jni
APP_STL := stlport_static
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions
转载请注明出处~亲们
转载于:https://www.cnblogs.com/heimi/archive/2012/12/15/2819391.html
标签:__,NDK,STL,makefile,源码,eabi,LDFLAGS,arm,DIR 来源: https://blog.csdn.net/weixin_33928137/article/details/94565767