当前位置:   article > 正文

ld: warning: ignoring file LIB, building for ARCH but attempting to link with file built for ARCH_ld: warning: ignoring file /usr/local/lib/libz.dyl

ld: warning: ignoring file /usr/local/lib/libz.dylib, building for ios-arm64

错误重放

作者在编译edk2/BaseTools时出现以下问题:

➜  BaseTools uname -a
Darwin MacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64 #作者环境
······
➜  BaseTools make
······
clang++ -o ../bin/VfrCompile  AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyntax.o VfrFormPkg.o VfrError.o VfrUtilityLib.o VfrCompiler.o -L../libs -lCommon
ld: warning: ignoring file ../libs/libCommon.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
  "_DebugMsg", referenced from:
      CVfrCompiler::OptionInitialization(int, char**) in VfrCompiler.o
      CVfrCompiler::AdjustBin() in VfrCompiler.o
  "_Error", referenced from:
      CVfrErrorHandle::PrintMsg(unsigned int, char*, char const*, char const*) in VfrError.o
      CVfrErrorHandle::HandleError(EFI_VFR_RETURN_CODE, unsigned int, char*) in VfrError.o
      CVfrErrorHandle::HandleWarning(EFI_VFR_WARNING_CODE, unsigned int, char*) in VfrError.o
  "_GetUtilityStatus", referenced from:
      _main in VfrCompiler.o
  "_LongFilePath", referenced from:
      CVfrStringDB::GetVarStoreNameFormStringId(unsigned short) in VfrUtilityLib.o
      CVfrCompiler::PreProcess() in VfrCompiler.o
      CVfrCompiler::Compile() in VfrCompiler.o
      CVfrCompiler::GenBinary() in VfrCompiler.o
      CVfrCompiler::GenCFile() in VfrCompiler.o
      CVfrCompiler::GenRecordListFile() in VfrCompiler.o
  "_PrintMessage", referenced from:
      CVfrCompiler::DebugError(char*, unsigned int, unsigned int, char const*, char const*, ...) in VfrCompiler.o
  "_SetPrintLevel", referenced from:
      _main in VfrCompiler.o
  "_SetUtilityName", referenced from:
      CVfrCompiler::OptionInitialization(int, char**) in VfrCompiler.o
  "_StringToGuid", referenced from:
      CVfrCompiler::OptionInitialization(int, char**) in VfrCompiler.o
  "_VerboseMsg", referenced from:
      CVfrErrorHandle::PrintMsg(unsigned int, char*, char const*, char const*) in VfrError.o
  "_Warning", referenced from:
      CVfrErrorHandle::HandleWarning(EFI_VFR_WARNING_CODE, unsigned int, char*) in VfrError.o
ld: symbol(s) not found for architecture x86_64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [GNUmakefile:45: ../bin/VfrCompile] Error 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39

错误原因

该问题是由于程序需要../libs/libCommon.a链接器ld无法链接libCommon.a导致的链接错误
经检查后发现由于作者电脑上安装了包括CommandLineTools llvm gnucc的3套编译环境,由于llvm-14 llvm-16 gnubinutils、语法和符号有所不同,所以导致了库文件不互相兼容的情况

解决方法

自行保留仅一套编译环境
以下仅供参考

brew unlink llvm binutils
  • 1

export PATH=/usr/bin:/usr/sbin:/bin:/sbin
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/351500
推荐阅读
相关标签
  

闽ICP备14008679号