C文件是mytest.c:爲什麼我在android ndk應用程序中得到錯誤的argc值?
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 [email protected]
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o [email protected]
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運行,其結果是不解給我:
Hello, world (i=3)!
**argc=33632**
哇,很奇怪!你確定你沒有通過任何參數嗎?檢查您的IDE的選項! – m0skit0
沒有參數。我不使用IDE,只能在shell中執行它 – kpld