在 iOS 中使用静态库的“架构 i386 的未定义符号”
Posted
技术标签:
【中文标题】在 iOS 中使用静态库的“架构 i386 的未定义符号”【英文标题】:"Undefined symbols for architecture i386" using a static library in iOS 【发布时间】:2012-01-20 11:29:36 【问题描述】:我正在尝试在 xcode 4.2 中创建一个静态库。
我正在按照this 教程中的步骤进行操作。但是,我收到以下错误:
Ld /Users/harishk/Library/Developer/Xcode/DerivedData/Testlib-ailufzhcoulmzrflyhfgbwqbiksx/Build/Products/Debug-iphonesimulator/Testlib.app/Testlib normal i386
cd /Users/harishk/Desktop/sl/Testlib
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/harishk/Library/Developer/Xcode/DerivedData/Testlib-ailufzhcoulmzrflyhfgbwqbiksx/Build/Products/Debug-iphonesimulator -L/Users/harishk/Desktop/sl/Testlib/Testlib/lib -L/Users/harishk/Desktop/sl/Testlib/../lib -L/Users/harishk/Desktop/sl/Testlib -F/Users/harishk/Library/Developer/Xcode/DerivedData/Testlib-ailufzhcoulmzrflyhfgbwqbiksx/Build/Products/Debug-iphonesimulator -filelist /Users/harishk/Library/Developer/Xcode/DerivedData/Testlib-ailufzhcoulmzrflyhfgbwqbiksx/Build/Intermediates/Testlib.build/Debug-iphonesimulator/Testlib.build/Objects-normal/i386/Testlib.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -objC -all_load -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -lSimpleLibrary -o /Users/harishk/Library/Developer/Xcode/DerivedData/Testlib-ailufzhcoulmzrflyhfgbwqbiksx/Build/Products/Debug-iphonesimulator/Testlib.app/Testlib
ld: warning: ignoring file /Users/harishk/Desktop/sl/lib/libSimpleLibrary.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MathFunctions", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
您是在尝试创建库还是尝试在应用程序中使用创建的库? 【参考方案1】:MathFunctions
类丢失。来自您的应用程序项目或来自您使用的SimpleLibrary.a
。确保它是构建的编译和链接步骤的一部分。
【讨论】:
以上是关于在 iOS 中使用静态库的“架构 i386 的未定义符号”的主要内容,如果未能解决你的问题,请参考以下文章