файл c mytest.c :
include "stdio.h"
include "stdlib.h"
int main(int argc, char** argv)
{
int i=1;
i+=2;
printf("Hello, world (i=%d)!\n", i);
printf("argc=%d\n", argc);
exit(0);
}
и Makefile :
APP := mytest
ROOT := /opt
INSTALL_DIR := /data/local/tmp
NDK_PLATFORM_VER := 8
ANDROID_NDK_ROOT := $(ROOT)/android-ndk-r5b
ANDROID_NDK_HOST := linux-x86
ANDROID_SDK_ROOT := /opt/android-sdk-linux_x86
PREBUILD := $(ANDROID_NDK_ROOT)/toolchains/arm-eabi-4.4.0/prebuilt/$(ANDROID_NDK_HOST)
ANDROID_NDK_BIN := $(PREBUILD)/bin
ANDROID_NDK_INC := $(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/include
ANDROID_NDK_LIB := $(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib
CC := $(ANDROID_NDK_BIN)/arm-eabi-gcc
CPP := $(ANDROID_NDK_BIN)/arm-eabi-g++
LIBCRT := $(ANDROID_NDK_LIB)/crtbegin_dynamic.o
CFLAGS := -fno-short-enums -I$(ANDROID_NDK_INC)
LFLAGS := -nostdlib -Wl,--entry=main,-rpath-link=$(ANDROID_NDK_LIB),-dynamic-linker=/system/bin/linker,-rpath=/system/lib $(ANDROID_NDK_LIB)/crtbegin_dynamic.o
LDFLAGS = -lgcc -lc -L$(ANDROID_NDK_LIB)
all: $(APP)
OBJS += $(APP).o
$(APP): $(OBJS)
$(CC) $(LFLAGS) $^ $(LDFLAGS) $(ANDROID_NDK_LIB)/crtend_android.o -o $@
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
install: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
shell:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell
run:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
clean:
@rm -f $(APP).o $(APP)
когда я запускаю make && make install && make run, результат озадачивает меня:
Hello, world (i=3)!
**argc=33632**