android编译错误及解决方法
1.设置编译选项为make -j5 TARGET_ARCH=x86 TARGET_PRODUCT=generic TARGET_SIMULATOR=false TARGET_BUILD_TYPE=release TARGET_OS=linux LOCAL_PRELINK_MODULE=false
2.build/core/envsetup.mk 中 91行 设置为x86(该步骤可以省略)
3.修改build/tools/dexpreopt目录中Android.mk为Android-arm.mk,不编译该模块(该模块以来与emulator)。
make: *** No rule to make target `out/target/product/generic/obj/lib/libdbus.so', needed by `out/target/product/generic/obj/EXECUTABLES/auth-agent_intermediates/LINKED/auth-agent'. Stop.
原因:libdbus.so模块未编译。external/dbus/dbus中mk文件只对TARGET_ARCH = arm时又作用。
4.修改external/dbus/dbus目录中Android.mk,TARGET_ARCH = x86,编译该模块。
system/core/libcutils/memset32.S: Assembler messages:
system/core/libcutils/memset32.S:38: Error: unknown pseudo-op: `.fnstart'
.
.
.
system/core/libcutils/memset32.S:93: Error: unknown pseudo-op: `.fnend'
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libcutils_intermediates/memset32.o] Error 1
原因:system/core/libcutils模块在TARGET_SIMULATOR=false时,对arm相关代码有依赖,依赖代码如下:
LOCAL_SRC_FILES := $(commonSources) memset32.S atomic-android-arm.S mq.c \
ashmem-dev.c
LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
5.修改system/core/libcutils目录中Android.mk中78行(ifneq ($(TARGET_SIMULATOR),true)),暂使用TARGET_SIMULATOR=true编译。
target thumb C: libwpa_client <= external/wpa_supplicant/wpa_ctrl.c
target thumb C: libwpa_client <= external/wpa_supplicant/os_unix.c
cc1: error: unrecognized command line option "-mabi=aapcs-linux"
cc1: error: unrecognized command line option "-mabi=aapcs-linux"
target thumb C: libnetutils <= system/core/libnetutils/dhcpclient.c
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libwpa_client_intermediates/wpa_ctrl.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libwpa_client_intermediates/os_unix.o] Error 1
原因:不识别的命令行选项-mabi=aapcs-linux
6.修改external/wpa_supplicant/目录中Android.mk 20行,去掉-mabi=aapcs-linux选项.
external/dbus/dbus/dbus-sysdeps-util-unix.c:48:27: error: sys/syslimits.h: No such file or directory
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libdbus_intermediates/dbus-sysdeps-util-unix.o] Error 1
原因:定义了HAVE_SYS_SYSLIMITS_H该宏,但无法找到sys/syslimits.h头文件。
7.修改external/dbus/config.h中197行,#undef HAVE_SYS_SYSLIMITS_H。
system/core/debuggerd/crashglue.S:5: Error: no such instruction: `ldr r0,=0xa5a50000'
system/core/debuggerd/crashglue.S:6: Error: no such instruction: `ldr r1,=0xa5a50001'
.
.
.
system/core/debuggerd/crashglue.S:28: Error: no such instruction: `b .'
target arm C: libc <= bionic/libc/bionic/malloc_leak.c
make: *** [out/target/product/generic/obj/EXECUTABLES/crasher_intermediates/crashglue.o] Error 1
原因:system/core/debuggerd模块依赖于arm.
8.修改system/core/debuggerd模块中的Android.mk.重命名为Android-arm.mk,暂不编译该模块。
9.修改bionic/libc/tools目录下的gensyscalls.py,生成x86架构的相关文件。
修改bionic/libc目录下的Android.mk文件,设置为x86.
make: *** 没有规则可以创建“out/target/product/generic/obj/SHARED_LIBRARIES/libc_intermediates/arch-x86/bionic/exidx_dynamic.o”需要的目标“bionic/libc/arch -x86/bionic/exidx_dynamic.c”。 停止。
原因:bionic/libc/arch-x86/bionic目录下无exidx_dynamic.c文件。
10.修改bionic/libc/目录中Android.mk文件,去掉“arch-x86/bionic/exidx_dynamic.c \”。
/usr/include/gnu/stubs-32.h:7:3: error: #error Applications may not define the macro _LIBC
In file included from /usr/include/stdio.h:75,
from bionic/libc/bionic/malloc_leak.c:30:
/usr/include/libio.h:354: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘attribute_hidden’
/usr/include/libio.h:355: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘attribute_hidden’
/usr/include/libio.h:356: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘attribute_hidden’
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libc_intermediates/bionic/malloc_leak.o] Error 1
原因:bionic/libc/Android.mk中设置了libc_common_cflags := -D_LIBC=1, 与/usr/include/gnu/stubs-32.h有冲突。
11.修改bionic/libc/Android.mk,去掉libc_common_cflags中 -d_LIBC=1.
In file included from bionic/libc/bionic/libc_init_dynamic.c:54:
bionic/libc/bionic/pthread_internal.h:45: 错误: expected specifier-qualifier-list before ‘__pthread_cleanup_t’
In file included from bionic/libc/bionic/libc_init_dynamic.c:56:
bionic/libc/bionic/libc_init_common.h:41: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
bionic/libc/bionic/libc_init_dynamic.c:60: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libc_intermediates/bionic/libc_init_dynamic.o] 错误 1
原因:暂未调查。