架构 i386 的未定义符号 - Lipo 错误?
Posted
技术标签:
【中文标题】架构 i386 的未定义符号 - Lipo 错误?【英文标题】:Undefined symbols for architecture i386 - Lipo error? 【发布时间】:2014-06-05 03:19:35 【问题描述】:我已经为 i386 和 armv7 编译了 libclang.a。我可以使用 i386 libclang.so 构建我的 ios 应用程序,但由于".dylib not found" error,它无法启动。然后我决定使用 lipo 创建 fat lib:
lipo -create ../i386/libclang.a ../armv7/libclang.a -output ../fat/libclang.a
并添加了 fat 库而不是 i386。
现在我遇到了多个构建错误:
Undefined symbols for architecture i386:
"llvm::TimeRecord::getCurrentTime(bool)", referenced from:
clang::cxindex::Logger::~Logger() in libclang.a(CIndex.o)
"llvm::raw_ostream::flush_nonempty()", referenced from:
clang::cxindex::Logger::~Logger() in libclang.a(CIndex.o)
"llvm::raw_ostream::write(char const*, unsigned long)", referenced from:
_clang_createTranslationUnit in libclang.a(CIndex.o)
_clang_parseTranslationUnit in libclang.a(CIndex.o)
_clang_saveTranslationUnit in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(CXTranslationUnitImpl*) in libclang.a(CIndex.o)
_clang_getCursorDisplayName in libclang.a(CIndex.o)
_clang_annotateTokens in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(clang::FileEntry const*) in libclang.a(CIndex.o)
...
"llvm::raw_ostream::write(unsigned char)", referenced from:
_clang_saveTranslationUnit in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(CXTranslationUnitImpl*) in libclang.a(CIndex.o)
_clang_tokenize in libclang.a(CIndex.o)
_clang_annotateTokens in libclang.a(CIndex.o)
clang::cxindex::Logger::~Logger() in libclang.a(CIndex.o)
"llvm::raw_ostream::operator<<(llvm::format_object_base const&)", referenced from:
_clang_getCursor in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(llvm::format_object_base const&) in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(CXSourceRange) in libclang.a(CIndex.o)
clang::cxindex::Logger::operator<<(CXSourceLocation) in libclang.a(CIndex.o)
clang::cxindex::Logger::~Logger() in libclang.a(CIndex.o)
"llvm::raw_ostream::operator<<(unsigned long)", referenced from:
clang::cxindex::Logger::~Logger() in libclang.a(CIndex.o)
_clang_formatDiagnostic in libclang.a(CIndexDiagnostic.o)
"llvm::MemoryBuffer::getMemBufferCopy(llvm::StringRef, llvm::StringRef)", referenced from:
这是否意味着 lipo 创建了不正确的 fat lib?我该如何解决?我需要该应用在 ios 模拟器和设备上运行。
PS。
MBA-Anton:llvm_34_ios_fat_installed asmirnov$ lipo -info ../iOS_Projects/StaticLibraryUsage2/StaticLibraryUsage2/libclang.a
Architectures in the fat file: ../iOS_Projects/StaticLibraryUsage2/StaticLibraryUsage2/libclang.a are: i386 armv7
PPS。 Xcode 构建命令行:
Ld /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/StaticLibraryUsage2.app/StaticLibraryUsage2 normal i386
cd /Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator -L/Users/asmirnov/Documents/dev/src/llvm_34_ios_fat_installed -L/Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2/StaticLibraryUsage2 -L/Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed/lib -F/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator -filelist /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/StaticLibraryUsage2.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework CoreGraphics -lclang -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/StaticLibraryUsage2_dependency_info.dat -o /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProjectE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/StaticLibraryUsage2.app/StaticLibraryUsage2
【问题讨论】:
【参考方案1】:我必须在项目中添加所有 libLLVM*.a 文件,并且项目编译成功。但我现在有运行时错误:
dyld: Library not loaded: @rpath/libclang.dylib
Referenced from: /Users/asmirnov/Library/Application Support/iPhone Simulator/7.1/Applications/99583E4A-2848-4D44-A3DC-88218D911B46/StaticLibraryUsage2.app/StaticLibraryUsage2
Reason: image not found
我不确定这是否是相关问题,或者我已经解决了该问题但现在遇到了另一个问题。
【讨论】:
以上是关于架构 i386 的未定义符号 - Lipo 错误?的主要内容,如果未能解决你的问题,请参考以下文章
Apple Mach-O 链接器错误/架构 i386 的未定义符号:
架构 i386 的未定义符号:_FlutterMethodNotImplemented