Android系统 —— 编译错误整理(持续更新)

Android系统 —— 编译错误整理(持续更新),第1张

目录 1. 更改源码目录名引发的错误2. 添加VNDK库(Vendor Native Development Kit)报错3. 头文件被重复包含3. 无法链接库文件,库文件丢失

1. 更改源码目录名引发的错误
FAILED: out/target/product/gin/abl.elf
/bin/bash -c "\$(pwd)/prebuilts/build-tools/linux-x86/bin/make -C bootable/bootloader/edk2 BOOTLOADER_OUT=../../../out/target/product/gin/obj/ABL_OBJ all PREBUILT_HOST_TOOLS=CC=/home/sun/project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/bin/clang\\ CXX=/home/sun/project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/bin/clang++\\ LDPATH=\"-fuse-ld=/home/sun/project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/bin/ld.lld\"\\ AR=/home/sun/project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/bin/llvm-ar PREBUILT_PYTHON_PATH=\$(pwd)/prebuilts/python/linux-x86/2.7.5/bin/python2 MAKEPATH=\$(pwd)/prebuilts/build-tools/linux-x86/bin/ BUILD_SYSTEM_ROOT_IMAGE=0 VERIFIED_BOOT=0 VERIFIED_BOOT_2=1 VERIFIED_BOOT_LE=0 USER_BUILD_VARIANT=0 DISABLE_PARALLEL_DOWNLOAD_FLASH=0 AB_RETRYCOUNT_DISABLE=0 DYNAMIC_PARTITION_SUPPORT=1 TARGET_SUPPORTS_EARLY_USB_INIT=0 CLANG_BIN=/home/sun/project/Android10_Project/vendor/qcom/proprietary/llvm-arm-toolchain-ship/8.0/bin/ CLANG_PREFIX=/home/sun/project/Android10_Project/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- ABL_USE_SDLLVM=true ABL_SAFESTACK=true SAFESTACK_SUPPORTED_CLANG_VERSION=6.0 CLANG_GCC_TOOLCHAIN=/home/sun/project/Android10_Project/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 TARGET_ARCHITECTURE=AARCH64 BOARD_BOOTLOADER_PRODUCT_NAME=gin USERDATAIMAGE_FILE_SYSTEM_TYPE=f2fs"

make: Entering directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2' Loading previous configuration from /home/sun/project/Android10_Project/bootable/bootloader/edk2/Conf/BuildEnv.sh
WORKSPACE: /home/sun/project/Android10_Project/bootable/bootloader/edk2
EDK_TOOLS_PATH: /home/sun/Project/Android10_Project/bootable/bootloader/edk2/BaseTools

CONF_PATH: /home/sun/project/Android10_Project/bootable/bootloader/edk2/Conf
make[1]: Entering directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools'
/home/sun/project/Android10_Project/prebuilts/build-tools/linux-x86/bin/make -C Source/C
make[2]: Entering directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools/Source/C'
Attempting to detect ARCH from 'uname -m': x86_64
Detected ARCH of X64 using uname.
mkdir -p .
/home/sun/project/Android10_Project/prebuilts/build-tools/linux-x86/bin/make -C Common make[3]: Entering directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools/Source/C/Common'
make[3]: *** No rule to make target '/home/sun/Project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/lib64/clang/9.0.3/include/stdint.h', needed by 'BasePeCoff.o'. Stop.

make[3]: Leaving directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools/Source/C/Common'
make[2]: *** [GNUmakefile:79: Common] Error 2
make[2]: Leaving directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools/Source/C'
make[1]: *** [GNUmakefile:25: Source/C] Error 2
make[1]: Leaving directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2/BaseTools'
make: *** [makefile:138: EDK_TOOLS_BIN] Error 2
make: Leaving directory '/home/sun/project/Android10_Project/bootable/bootloader/edk2'
17:08:52 Disallowed PATH tool "pkg-config" used: []string{"pkg-config", "--cflags", "ncursesw"}
17:08:52 See https://android.googlesource.com/platform/build/+/master/Changes.md#PATH_Tools for more information.

错误一: “EDK_TOOLS_PATH: /home/sun/Project/Android10_Project/bootable/bootloader/edk2/BaseTools”

(1) 问题描述:
EDK_TOOLS_PATH的路径不对,同步代码的时候我建的文件夹确实叫做"Project",但是后来我给改成了"project",没想到android的编译系统这么弱智,这都同步不了

(2) 解决办法:
进入EDK_TOOLS_PATH的上一级目录,然后执行下面命令

rm -rf Conf/BuildEnv.sh
unset EDK_TOOLS_PATH
./edksetup.sh BaseTools

错误二: “make[3]: *** No rule to make target ‘/home/sun/Project/Android10_Project/prebuilts/clang/host/linux-x86/clang-r353983c1/lib64/clang/9.0.3/include/stdint.h’, needed by ‘BasePeCoff.o’. Stop.”

(1) 问题描述:
这个其实和上面的错误一个道理,都是旧目录名称没有更新(旧目录叫“Project”,新目录叫“project”)

(2) 解决办法:
上个错误已解决的基础上,在EDK_TOOLS_PATH目录,执行make clean即可。


2. 添加VNDK库(Vendor Native Development Kit)报错
[ 5% 634/10974] build out/target/product/trinket/obj/PACKAGING/vndk_intermediates/check-list-timestamp
FAILED: out/target/product/trinket/obj/PACKAGING/vndk_intermediates/check-list-timestamp /bin/bash -c "(( diff --old-line-format=\"Removed %L\" --new-line-format=\"Added %L\" --unchanged-line-format=\"\" build/make/target/product/gsi/29.txt out/target/product/trinket/obj/PACKAGING/vndk_intermediates/libs.txt || ( echo -e \" error: VNDK library list has been changed.\\n\" \" Changing the VNDK library list is not allowed in API locked branches.\"; exit 1 )) ) && (mkdir -p out/target/product/trinket/obj/PACKAGING/vndk_intermediates/ ) && (touch out/target/product/trinket/obj/PACKAGING/vndk_intermediates/check-list-timestamp )"
Added VNDK-core: libturbo_jpeg.so
error: VNDK library list has been changed.
Changing the VNDK library list is not allowed in API locked branches.

问题描述: 看报错内容,可以知道是用diff命令对29.txt和libs.txt的内容进行了逐行比较,因两个文件内容不一致而导致的问题。至于为什么不一样,那是因为由于项目原因,需要添加一个名为libturbo_jpeg的VNDK动态库,在编译的时候新库名字被写到了libs.txt,而29.txt还是原先内容
动态库的创建是在external/libjpeg-turbo/Android.bp中,如下

cc_library {
    name: "libturbo_jpeg",
    host_supported: true,
    vendor_available: true,  //VNDK库需要设置为true
    vndk: {
        enabled: true,      //VNDK库需要设置为true
    },
    defaults: ["libjpeg-defaults"],
    export_include_dirs: ["."],
    target: {
        windows: {
            enabled: true,
        },
    },
    srcs: [
        "jdatadst-tj.c",
        "jdatasrc-tj.c",
		"turbojpeg.c",
		"transupp.c",
		"rdbmp.c",
		"rdppm.c",
		"wrbmp.c",
        "wrppm.c",
            ],
    cflags: [
        "-DBMP_SUPPORTED",
        "-DPPM_SUPPORTED",
        "-Werror",
        "-Wno-unused-parameter",
    ],
}

解决方法:
将libs.txt的内容直接全部拷贝到29.txt中即可


3. 头文件被重复包含
FAILED:
build/make/core/main.mk:1158: warning: "xxf : _modules_xxx_cut" =
build/make/core/Makefile:76: warning: Duplicate header copy: out/target/product/myproject/obj/include/mycarcam/mycarcam.h
build/make/core/Makefile:76: warning: _ Using vendor/qcom/proprietary/mm-camera/ais/API/inc/mycarcam.h
build/make/core/Makefile:76: warning: __ from vendor/qcom/proprietary/mm-camera/ais/libais_client.mk
build/make/core/Makefile:76: warning: _ Ignoring vendor/qcom/proprietary/mm-camera/ais/API/inc/mycarcam.h
build/make/core/Makefile:76: warning: __ from vendor/qcom/proprietary/mm-camera/ais/libais_client.mk
build/make/core/Makefile:76: warning: Duplicate header copy: out/target/product/myproject/obj/include/mycarcam/mycarcam_types.h
build/make/core/Makefile:76: warning: _ Using vendor/qcom/proprietary/mm-camera/ais/API/inc/mycarcam_types.h
build/make/core/Makefile:76: warning: __ from vendor/qcom/proprietary/mm-camera/ais/libais_client.mk
build/make/core/Makefile:76: warning: _ Ignoring vendor/qcom/proprietary/mm-camera/ais/API/inc/mycarcam_types.h
build/make/core/Makefile:76: warning: __ from vendor/qcom/proprietary/mm-camera/ais/libais_client.mk
build/make/core/Makefile:95: error: duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers.

问题描述: 看error那行,意思是不再允许拷贝重复的头文件,然后我们再看上面的warning,发现编译过程中mycarcam.h和mycarcam_types.h被重复拷贝了,这是不被允许的(不过我试过只重复一个文件就没问题,费解。。。)

解决方法: 经过排查是mk文件中,这两个头文件被重复拷贝了,可根据项目实际情况进行添加条件避免重复拷贝


3. 无法链接库文件,库文件丢失
[ 99% 365/366] finishing build rules ...
FAILED:
vendor/qcom/proprietary/pis/test/test_util/Android.mk: error: "libpis_test_util (native:platform) can not link against libimg (native:vendor)"
vendor/qcom/proprietary/pis/test/test_util/Android.mk: error: "libpis_test_util (SHARED_LIBRARIES android-arm64) missing libjpeg (SHARED_LIBRARIES android-arm64)"
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
...
build/make/core/main.mk:959: error: exiting from previous errors.
14:45:48 ckati failed with: exit status 1

#### failed to build some targets (02:46 (mm:ss)) ####

错误一: “libpis_test_util (native:platform) can not link against libimg (native:vendor)”
(1) 错误分析:
  这个error表达的是库libpis_test_util(native:platform)不能链接库libimg (native:vendor)。看下面两个Android.mk文件,libpis_test_util(native:platform)用链接系统库的方式链接了vendor库,这个肯定是不行。

libpis_test_util的Android.mk:

...//省略
LOCAL_MODULE := libpis_test_util
LOCAL_HEADER_LIBRARIES := libtest_headers
LOCAL_SHARED_LIBRARIES += libtest libimg libjpeg      //LOCAL_SHARED_LIBRARIES这个flag是用来链接系统库的
...//省略

libimg的Android.mk:

...//省略
include $(CLEAR_VARS)
LOCAL_MODULE        := libimg
LOCAL_MODULE_CLASS  := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_STRIP_MODULE  := false
LOCAL_MULTILIB      := 64
LOCAL_MODULE_OWNER  := qcom
LOCAL_MODULE_TAGS   := optional
LOCAL_SRC_FILES     := ../../.././target/product/xxx/system/lib64/libimg.so
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/system/lib64
LOCAL_PROPRIETARY_MODULE := true     //这里可以看到libimg库是属于proprietary的,也就是vendor的模块
include $(BUILD_PREBUILT)
...//省略

(2) 解决方法:
 把libimg的Android.mk中的LOCAL_PROPRIETARY_MODULE置为false,或者把libpis_test_util的Android.mk中的LOCAL_SHARED_LIBRARIES改为LOCAL_LDFLAGS(就是把链接方式由链接系统库改为链接第三方库)

错误二: “libpis_test_util (SHARED_LIBRARIES android-arm64) missing libjpeg (SHARED_LIBRARIES android-arm64)”
(1) 错误分析:
  这个error表达的是编译系统没有找到libjpeg库,通过查看是没有为libjpeg库添加编译规则

(2) 解决方法:
  在对应的Android.mk中加入编译规则,对应内容如下所示:

include $(CLEAR_VARS)
LOCAL_MODULE        := libjpeg
LOCAL_MODULE_CLASS  := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX := .so
LOCAL_STRIP_MODULE  := false
LOCAL_MULTILIB      := 64
LOCAL_MODULE_OWNER  := qcom
LOCAL_MODULE_TAGS   := optional
LOCAL_SRC_FILES     := ../../.././target/product/xxx/system/lib64/libjpeg.so
LOCAL_MODULE_PATH   := $(PRODUCT_OUT)/system/lib
include $(BUILD_PREBUILT)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/992148.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存