ld.lld的unknown file type错误

报错

  在一次编译aosp源码中,出现以下错误:

FAILED: //external/pdfium:libpdfium link libpdfium.so [arm]
Outputs: out/soong/.intermediates/external/pdfium/libpdfium/android_arm_armv8-a_shared/unstripped/libpdfium.so
Error: exited with code: 1
Command: prebuilts/clang/host/linux-x86/clang-r416183b1/bin/clang++ out/soong/.intermediates/bionic/libc/crtbegin_so/android_arm_armv8-a/crtbegin_so.o @out/soong/.intermediates/external/pdfium/libpdfium/android_arm_armv8-a_shared/unstripped/libpdfium.so.rsp -Wl,--whole-archive  out/soong/.intermediates/external/pdfium/fpdfsdk/libpdfium-fpdfsdk/android_arm_armv8-a_static/libpdfium-fpdfsdk.a -Wl,--no-whole-archive  out/soong/.intermediates/external/pdfium/core/fpdfapi/edit/libpdfium-edit/android_arm_armv8-a_static/libpdfium-edit.a out/soong/.intermediates/external/pdfium/fpdfsdk/formfiller/libpdfium-formfiller/android_arm_armv8-a_static/libpdfium-formfiller.a out/soong/.intermediates/external/pdfium/core/fpdftext/libpdfium-fpdftext/android_arm_armv8-a_static/libpdfium-fpdftext.a out/soong/.intermediates/external/pdfium/fxjs/libpdfium-fxjs/android_arm_armv8-a_static/libpdfium-fxjs.a out/soong/.intermediates/external/pdfium/fpdfsdk/pwl/libpdfium-pwl/android_arm_armv8-a_static/libpdfium-pwl.a out/soong/.intermediates/external/pdfium/core/fpdfdoc/libpdfium-fpdfdoc/android_arm_armv8-a_static/libpdfium-fpdfdoc.a out/soong/.intermediates/external/pdfium/core/fpdfapi/render/libpdfium-render/android_arm_armv8-a_static/libpdfium-render.a out/soong/.intermediates/external/pdfium/core/fpdfapi/page/libpdfium-page/android_arm_armv8-a_static/libpdfium-page.a out/soong/.intermediates/external/pdfium/core/fpdfapi/font/libpdfium-font/android_arm_armv8-a_static/libpdfium-font.a out/soong/.intermediates/external/pdfium/core/fpdfapi/cmaps/libpdfium-cmaps/android_arm_armv8-a_static/libpdfium-cmaps.a out/soong/.intermediates/external/pdfium/core/fpdfapi/parser/libpdfium-parser/android_arm_armv8-a_static/libpdfium-parser.a out/soong/.intermediates/external/pdfium/core/fdrm/libpdfium-fdrm/android_arm_armv8-a_static/libpdfium-fdrm.a out/soong/.intermediates/external/pdfium/core/fxcodec/libpdfium-fxcodec/android_arm_armv8-a_static/libpdfium-fxcodec.a out/soong/.intermediates/external/pdfium/third_party/libpdfium-libopenjpeg2/android_arm_armv8-a_static/libpdfium-libopenjpeg2.a out/soong/.intermediates/external/pdfium/core/fxge/libpdfium-fxge/android_arm_armv8-a_static/libpdfium-fxge.a out/soong/.intermediates/external/pdfium/third_party/libpdfium-agg/android_arm_armv8-a_static/libpdfium-agg.a out/soong/.intermediates/external/pdfium/core/fxcrt/libpdfium-fxcrt/android_arm_armv8-a_static/libpdfium-fxcrt.a out/soong/.intermediates/external/pdfium/third_party/libpdfium-skia_shared/android_arm_armv8-a_static/libpdfium-skia_shared.a out/soong/.intermediates/external/pdfium/third_party/libpdfium-third_party-base/android_arm_armv8-a_static/libpdfium-third_party-base.a out/soong/.intermediates/external/pdfium/third_party/libpdfium-lcms2/android_arm_armv8-a_static/libpdfium-lcms2.a out/soong/.intermediates/external/libcxxabi/libc++demangle/android_arm_armv8-a_static/libc++demangle.a prebuilts/clang/host/linux-x86/clang-r416183b1/lib64/clang/12.0.7/lib/linux/libclang_rt.builtins-arm-android.a out/soong/.intermediates/external/freetype/libft2/android_arm_armv8-a_shared/libft2.so out/soong/.intermediates/external/icu/libicu/libicu/android_arm_armv8-a_shared_current/libicu.so out/soong/.intermediates/external/libjpeg-turbo/libjpeg/android_arm_armv8-a_shared/libjpeg.so out/soong/.intermediates/external/zlib/libz/android_arm_armv8-a_shared/libz.so out/soong/.intermediates/external/libcxx/libc++/android_arm_armv8-a_shared/libc++.so out/soong/.intermediates/bionic/libc/libc/android_arm_armv8-a_shared_current/libc.so out/soong/.intermediates/bionic/libm/libm/android_arm_armv8-a_shared_current/libm.so out/soong/.intermediates/bionic/libdl/libdl/android_arm_armv8-a_shared_current/libdl.so out/soong/.intermediates/bionic/libc/crtend_so/android_arm_armv8-a/obj/bionic/libc/arch-common/bionic/crtend_so.o -o out/soong/.intermediates/external/pdfium/libpdfium/android_arm_armv8-a_shared/unstripped/libpdfium.so -target armv7a-linux-androideabi10000 -Bprebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/bin -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined-version -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_stripped.a -Wl,--exclude-libs,libunwind_llvm.a -Wl,--exclude-libs,libunwind.a -Wl,--icf=safe -fuse-ld=lld -Wl,--pack-dyn-relocs=android+relr -Wl,--no-undefined -Wl,--hash-style=gnu -Wl,-m,armelf -Wl,--exclude-libs=libclang_rt.builtins-arm-android.a  -nostdlib -Wl,--gc-sections -shared -Wl,-soname,libpdfium.so -Wl,-icf=all 
Output:
ld.lld: error: out/soong/.intermediates/external/pdfium/third_party/libpdfium-libopenjpeg2/android_arm_armv8-a_static/libpdfium-libopenjpeg2.a: unknown file type
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

  报错提示libpdfium-libopenjpeg2.a无法被ld.lld识别,被标记为unknown file type。

解决方法

  先用file命令查看libpdfium-libopenjpeg2.a的文件属性。正常的静态库文件会作以下提示,表明这是一个正确的静态库:

libpdfium-libopenjpeg2.a:current ar archive

  但是这里确提示"empty",表明这是一个空文件。

  于是,我删掉out/soong/.intermediates/external/pdfium下面的所有文件,重新正确编译生成libpdfium-libopenjpeg2.a后,此错误被修复。

你可能感兴趣的:(编译系统,android)