zoukankan      html  css  js  c++  java
  • 关于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

    转载请注明出处~亲们

  • 相关阅读:
    [组合][DP]luogu P3643 [APIO2016]划艇
    [倍增]luogu P4155 [SCOI2015]国旗计划
    [并查集][线段树]luogu P3273 [SCOI2011]棘手的操作
    pytest警告DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
    docker-compose5分钟搭建wordpress博客网站
    Docker安装入门
    Windows10安装wget命令
    CRC (Cyclic Redundancy Check)
    Linux学习笔记
    Linux学习笔记
  • 原文地址:https://www.cnblogs.com/heimi/p/2819391.html
Copyright © 2011-2022 走看看