赞
踩
作者在编译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
该问题是由于程序需要../libs/libCommon.a
但链接器ld
无法链接libCommon.a
导致的链接错误
经检查后发现由于作者电脑上安装了包括CommandLineTools
llvm
gnucc
的3套编译环境,由于llvm-14
llvm-16
gnu
的binutils
、语法和符号有所不同,所以导致了库文件不互相兼容的情况
自行保留仅一套编译环境
以下仅供参考
brew unlink llvm binutils
或
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。