Android Studio 解决:error adding symbols: File in wrong format clang++.exe: error: linker command......

本文介绍了一种在Android Studio中遇到的构建失败问题及其解决方案。错误主要发生在使用CMake进行外部原生构建时,提示libs文件夹下的架构包缺失。通过在build.gradle文件的ndk模块中添加abiFilters'armeabi'解决了该问题。
错误日志:
Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing 'D:\java\androidstudio\sdk\cmake\3.6.4111459\bin\cmake.exe' with arguments {--build F:\test\FFmpegTest\app\.externalNativeBuild\cmake\debug\mips64 --target native-lib}
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\mips64\libnative-lib.so
FAILED: cmd.exe /C "cd . && D:\java\androidstudio\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe  --target=mips64el-none-linux-android --gcc-toolchain=D:/java/androidstudio/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/windows-x86_64 --sysroot=D:/java/androidstudio/sdk/ndk-bundle/sysroot -fPIC -isystem D:/java/androidstudio/sdk/ndk-bundle/sysroot/usr/include/mips64el-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fintegrated-as -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a --sysroot D:/java/androidstudio/sdk/ndk-bundle/platforms/android-21/arch-mips64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\mips64\libnative-lib.so CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o  ../../../../libs/armeabi-v7a/libswresample-2.so ../../../../libs/armeabi-v7a/libavcodec-57.so ../../../../libs/armeabi-v7a/libavfilter-6.so ../../../../libs/armeabi-v7a/libswscale-4.so ../../../../libs/armeabi-v7a/libavdevice-57.so ../../../../libs/armeabi-v7a/libavformat-57.so -llog -lm "D:/java/androidstudio/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/libgnustl_static.a" && cd ."
../../../../libs/armeabi-v7a/libswresample-2.so: error adding symbols: File in wrong format
  clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

错误原因:

libs文件夹下的架构包缺失,使用ndk abi过滤器过滤即可解决。

解决:

在build.gradle中ndk模块中添加下面的代码:abiFilters 'armeabi'
添加后的代码长这样:

ndk {
      abiFilters 'armeabi'
    }
这是什么报错:enerating /home/lwx1157713/hixuanxuan/HiXuanyuan/platform/aiot/Hi2131_V100R001C10SPC103B060/drivers/chips/cat1/board/linker/app_core/linker_rom.prelds -> /home/lwx1157713/hixuanxuan/HiXuanyuan/platform/aiot/Hi2131_V100R001C10SPC103B060/output/cat1/acore/application-cat1-tts/linker_rom.lds Generating -> /home/lwx1157713/hixuanxuan/HiXuanyuan/platform/aiot/Hi2131_V100R001C10SPC103B060/output/cat1/acore/application-cat1-tts/linker_check_rom.lds /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): relocations in generic ELF (EM: 40) /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): error adding symbols: file in wrong format clang-15: error: ld command failed with exit code 1 (use -v to see invocation) CMakeFiles/application_cat1.dir/build.make:214: recipe for target 'application_cat1.elf' failed make[2]: *** [application_cat1.elf] Error 1 CMakeFiles/Makefile2:6012: recipe for target 'CMakeFiles/application_cat1.dir/all' failed make[1]: *** [CMakeFiles/application_cat1.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): relocations in generic ELF (EM: 40) /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): error adding symbols: file in wrong format clang-15: error: ld command failed with exit code 1 (use -v to see invocation) CMakeFiles/application_cat1_rom.dir/build.make:256: recipe for target 'application_cat1_rom.elf' failed make[2]: *** [application_cat1_rom.elf] Error 1 CMakeFiles/Makefile2:4701: recipe for target 'CMakeFiles/application_cat1_rom.dir/all' failed make[1]: *** [CMakeFiles/application_cat1_rom.dir/all] Error 2 /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): relocations in generic ELF (EM: 40) /home/lwx1157713/llvm-binary-relese-musl/linx-llvm-binary-release-musl/bin/riscv32/riscv32-raw/ld: ../../../../middleware/chips/cat1/ipc_components/hichannel/build/lib/libhichannel.a(channel_interface.c.o): error adding symbols: file in wrong format clang-15: error: ld command failed with exit code 1 (use -v to see invocation) CMakeFiles/application_cat1_check_rom.dir/build.make:256: recipe for target 'application_cat1_check_rom.elf' failed make[2]: *** [application_cat1_check_rom.elf] Error 1 CMakeFiles/Makefile2:4448: recipe for target 'CMakeFiles/application_cat1_check_rom.dir/all' failed make[1]: *** [CMakeFiles/application_cat1_check_rom.dir/all] Error 2 Makefile:90: recipe for target 'all' failed make: *** [all] Error 2 ######### Build target:application_cat1_tts failed
最新发布
09-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值