更新时间:2022-12-01 09:59:28
将近一年过去了,但这里是一个makefile,将编译一个简单的本机应用程序:
Almost a year later, but here is a makefile that will compile a simple native app:
NDK_USR_PATH := $(NDK_USR)
C_FILES := $(wildcard *.c) $(wildcard *.cpp)
O_FILES := $(patsubst %.cpp,%.o,$(C_FILES))
O_FILES := $(patsubst %.c,%.o,$(C_FILES))
out: $(O_FILES)
@arm-eabi-gcc -o $@ $< -Bdynamic -Wl,--gc-section -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,--dynamic-linker=/system/bin/linker -Wl,-rpath-link=$(NDK_USR_PATH)/lib -nostdlib $(NDK_USR_PATH)/lib/crtend_android.o $(NDK_USR_PATH)/lib/crtbegin_dynamic.o -L$(NDK_USR_PATH)/lib -lc
%.o: %.c
@arm-eabi-gcc -o $@ $< -c -I$(NDK_USR_PATH)/include -fno-short-enums
clean:
@rm -f *.o
@rm -f out
它编译在同一个目录中的任何.c文件到一个名为走出去的应用程序。它要求环境变量NDK_USR指向NDK目录NDK / Android的NDK-R7 /平台/ Android的14 /弓臂的/ usr /\".
It compiles any .c files in the same directory into an app named "out". It requires the environment variable NDK_USR to point to the ndk directory "ndk/android-ndk-r7/platforms/android-14/arch-arm/usr/".
这应该动态链接到libc的仿生,并应启用Android驱动开发。
This should dynamically link to the bionic libc, and should enable android driver development.
复制时要小心和粘贴上面的Makefile。提出的是非常具***表符。
Be careful when copying and pasting the above makefile. Make is very specific about tab characters.