clang:错误:链接器命令失败,退出码为1-找不到库。

4

我在构建项目时遇到了一些问题。自上周以来,我一直遇到以下错误,但无法摆脱它。

Ld /Users/Nathan/Library/Developer/Xcode/DerivedData/SmartPic-elnbgmemojraijcotdlcskagbibq/Build/Products/Debug-iphoneos/SmartPic.app/SmartPic normal armv7
    cd "/Users/Nathan/Documents/Xcode Projects/SmartPic"
    setenv IPHONEOS_DEPLOYMENT_TARGET 4.3
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
-L/Users/Nathan/Library/Developer/Xcode/DerivedData/SmartPic-elnbgmemojraijcotdlcskagbibq/Build/Products/Debug-iphoneos
-F/Users/Nathan/Library/Developer/Xcode/DerivedData/SmartPic-elnbgmemojraijcotdlcskagbibq/Build/Products/Debug-iphoneos -filelist /Users/Nathan/Library/Developer/Xcode/DerivedData/SmartPic-elnbgmemojraijcotdlcskagbibq/Build/Intermediates/SmartPic.build/Debug-iphoneos/SmartPic.build/Objects-normal/armv7/SmartPic.LinkFileList -dead_strip -miphoneos-version-min=4.3 -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework EventKit -framework EventKitUI -framework MessageUI -lz -framework CoreLocation -framework UIKit -framework Foundation -framework CoreGraphics -framework QuartzCore -framework AVFoundation -framework CoreMedia -framework CoreMotion -framework CoreVideo -framework AudioToolbox -lDMReader -o /Users/Nathan/Library/Developer/Xcode/DerivedData/SmartPic-elnbgmemojraijcotdlcskagbibq/Build/Products/Debug-iphoneos/SmartPic.app/SmartPic

ld: library not found for -lDMReader
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我搜索了关于这个错误的信息,因为曾经我有6个类似的错误,答案是在“构建设置”中删除库搜索路径,这样就可以解决除了这个问题以外的所有问题。一切都很顺利,直到我引入了一些额外的框架和类。所以我不太确定是什么导致了这个错误,以及如何修复它。
我对应用程序开发还比较新,请尽量不要过于技术化。
非常感谢您的帮助,谢谢。
1个回答

4

通过更改构建设置中的库搜索路径来解决这个问题:

./Classes "$(SRCROOT)/Classes"

以防其他人发现此问题并想尝试解决。

编辑: 刚才我又遇到了同样的问题。原因是我更改了与.xcodeproj文件相邻的文件夹名称。因此,在我的Mac上的一个文件夹中,我有一个名为“应用程序名称”的目录和一个名为“应用程序名称.xcodeproj”的文件。我将目录“应用程序名称”更改为其他内容,并且尽管在xcode中更新了构建设置,仍然遇到了同样的问题。我需要执行以下操作:

  • 右键单击 App Name.xcodeproj
  • 点击 Show Package Contents
  • 打开 project.pbxproj
  • 然后使用 cmd + f (搜索) 并输入 App Name,我认为页面的下方有两个位置,称为 name 和紧接其下面的path。将它们更改为新的目录名称,保存并重新打开您的项目,一切都应该没问题了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接