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
原因:暫未調查。

 

摘自 C'est la vie

發佈留言