iphone - ".../libtool: can' t 找到 : -lxml2"的文件

标签 iphone objective-c ios libxml2

我在 xcode 工作区中有 2 个项目。一种是静态库,一种是使用静态库。

在静态库中,我添加了我在主项目中使用的 GDataXMLNode.h 和 GDataXMLNode.m 文件。 GDataXMLNode.h 是一个公共(public)文件,因此它在主项目中可见。我还将这两个项目的目标与 libxml2.dylib 链接起来。我还在 header 搜索路径和用户 header 搜索路径中包含位置/usr/include/libxml2。

尽管如此,我还是遇到了 Apple Mach-O 图书管理员错误:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: can't locate file for: -lxml2
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: file: -lxml2 is not an object file (not allowed in a library)
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libxml2.dylib is a dynamic library, not added to the static library
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libxml2.dylib is a dynamic library, not added to the static library
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool failed with exit code 1

你知道我该如何解决这个问题吗?

最佳答案

我最近遇到了完全相同的错误。如您所见,从build设置中的“其他链接器标志”中删除“-lxml2”有助于解决错误。当您构建静态库时,情况确实如此。您需要在实际包含您的静态库的任何目标中包含该链接器标志(“-lxml2”)。例如,如果您像我一样为静态库创建了单元测试(即 MyStaticLibraryProjectTests),那么您需要确保将链接器标志添加到 MyStaticLibraryProjectTests 目标,而不是实际的 MyStaticLibraryProject 目标。当我去查看我的build设置选项卡时,我通常会忘记选择一个特定的目标。我通常假设,如果我单击蓝色大项目图标,build设置仅适用于整个项目,但在修改这些设置时选择正确的目标非常重要。

大多数项目的早期通常只有一个目标,但随着您变得更高级,每个项目可能有多个目标。希望对您有所帮助。

关于iphone - ".../libtool: can' t 找到 : -lxml2"的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7482285/

相关文章:

iphone - 自定义事件循环和 UIKit 控件。苹果的事件循环有什么额外的魔力?

ios - 如何调试 bad access code 2 错误?

ios - UISegmentedControl 的 3 段中的第一个占宽度的一半

ios - 在 iPhone ARM64 调用约定中,寄存器 $x1 中的内容是什么?

iphone - 解除分配当前/上一个 View Controller

iOS:从任何地方返回 Root View Controller

ios - Facebook iOS SDK - 发布自定义故事

iphone - RestKit 应用程序因 [NSPathStore2 stringByAppendingQueryParameters :]: unrecognized selector message 而崩溃

iphone - 具有特定时间间隔的IOS后台任务

ios - 当我使用 NSPredicate 为我的 UITableView 过滤我的数组时,应用程序崩溃