如何修复Mach-O Linker错误 [英] How to fix compile Mach-O Linker error

查看:51
本文介绍了如何修复Mach-O Linker错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将此iOS库 PTImageAlbumViewController 添加到我正在处理的现有项目中而且我遇到了编译错误.其中包含一个示例项目,它依赖于其他两个库.该示例项目运行正常,但是我无法毫无错误地将其迁移到我自己的项目中.我尝试通过将文件从一个项目拖到另一个项目来直接从项目中拉出文件,但仍然无法使用

I'm trying to add this iOS lib PTImageAlbumViewController to an existing project that I'm working on and I'm getting compile errors. There is a sample project included and its dependent on a couple of other libs. The sample project works just fine but I can't get it migrated to my own project without errors. I tried pulling the files direct from the project by dragging them from project to project but its still not working

有什么我想念的吗?

架构armv7的未定义符号:从以下位置引用的"_OBJC_METACLASS _ $ _ NetworkPhotoAlbumViewController"PTImageAlbumViewController.o中的_OBJC_METACLASS _ $ _ PTImageAlbumViewController从以下位置引用的"_OBJC_CLASS _ $ _ NIPhotoAlbumScrollView"PTImageAlbumView.o中的_OBJC_CLASS _ $ _ PTImageAlbumView从以下位置引用的"_OBJC_CLASS _ $ _ NetworkPhotoAlbumViewController"PTImageAlbumViewController.o中的_OBJC_CLASS _ $ _ PTImageAlbumViewController从以下位置引用的"_NIPathForBundleResource"-PTImageAlbumViewController.o中的[PTImageAlbumViewController viewDidLoad]从以下位置引用的"_OBJC_METACLASS _ $ _ NIPhotoAlbumScrollView"PTImageAlbumView.o中的_OBJC_METACLASS _ $ _ PTImageAlbumViewld:找不到架构armv7的符号clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

Undefined symbols for architecture armv7: "_OBJC_METACLASS_$_NetworkPhotoAlbumViewController", referenced from: _OBJC_METACLASS_$_PTImageAlbumViewController in PTImageAlbumViewController.o "_OBJC_CLASS_$_NIPhotoAlbumScrollView", referenced from: _OBJC_CLASS_$_PTImageAlbumView in PTImageAlbumView.o "_OBJC_CLASS_$_NetworkPhotoAlbumViewController", referenced from: _OBJC_CLASS_$_PTImageAlbumViewController in PTImageAlbumViewController.o "_NIPathForBundleResource", referenced from: -[PTImageAlbumViewController viewDidLoad] in PTImageAlbumViewController.o "_OBJC_METACLASS_$_NIPhotoAlbumScrollView", referenced from: _OBJC_METACLASS_$_PTImageAlbumView in PTImageAlbumView.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

推荐答案

找不到nimbus文件.

What it can't find is the nimbus files.

如果您已将nimbus和SDURLCache文件添加到项目中,那么只需确保它们已包含在应用程序的目标中即可.

If you have added the nimbus and SDURLCache files to your project, then it should just be a matter of making sure they're included in your application's target.

确保所有文件都已进入您的项目并位于正确的目标中.例如,第一个错误与NetworkPhotoAlbumViewController.m有关.该文件在您的项目中并在正确的目标中吗?

Make sure ALL the files got into your project and are in the right target. For example, the first error is regarding NetworkPhotoAlbumViewController.m. Is that file in your project and in the right target?

如果是这样,另一种可能性是由于某种原因它没有为此架构而构建.您可以通过从DerivedData目录中导航树到存储目标文件的位置,然后使用nm在目标文件中搜索缺少的符号来找到答案.

If so, the one other possibility is that it's simply not building for this architecture for some reason. You can find out by navigating the tree from your DerivedData directory down to where the object files are stored and using nm to search the object files for the missing symbols.

我的机器上的示例:

cd /Users/username/Library/Developer/Xcode/DerivedData/AlbumDemo-eyqszubjyqhczreurkblqktoxjja/Build/Intermediates/AlbumDemo.build/Debug-iphonesimulator/AlbumDemo.build/Objects-normal/i386

nm NetworkPhotoAlbumViewController.o | grep _NetworkPhotoAlbumViewController
00000000 t -[NetworkPhotoAlbumViewController shutdown_NetworkPhotoAlbumViewController]
0000e0fc s -[NetworkPhotoAlbumViewController shutdown_NetworkPhotoAlbumViewController].eh
0000cde8 S _OBJC_CLASS_$_NetworkPhotoAlbumViewController
0000c9b4 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._activeRequests
0000c9bc S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._highQualityImageCache
0000c9b0 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._queue
0000c9b8 S _OBJC_IVAR_$_NetworkPhotoAlbumViewController._thumbnailImageCache
0000cdfc S _OBJC_METACLASS_$_NetworkPhotoAlbumViewController
0000cfe0 s l_OBJC_$_INSTANCE_METHODS_NetworkPhotoAlbumViewController
0000d084 s l_OBJC_$_INSTANCE_VARIABLES_NetworkPhotoAlbumViewController
0000d0e0 s l_OBJC_$_PROP_LIST_NetworkPhotoAlbumViewController
0000d100 s l_OBJC_CLASS_RO_$_NetworkPhotoAlbumViewController
0000cfb8 s l_OBJC_METACLASS_RO_$_NetworkPhotoAlbumViewController

这些符号在第二列中没有"U"的事实意味着它们是在此目标文件中定义的.您可以从

The fact that these symbols do not have a "U" in the second column means that they are defined in this object file. You can find the meaning of all the nm output from the nm man page.

这篇关于如何修复Mach-O Linker错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆