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/

相关文章:

ios - iPhone 6 的不同 Storyboard

iphone - 如何确定ios用户是否登录到twitter?

iphone - 带定时器的 NSOperationQueue

objective-c - CoreAnimation,在 iOS 5 Xcode 4 中移动带有动画阴影的 UIImageView

objective-c - 在源列表中显示固定和可编辑的项目

ios - 在我的 iPhone 上运行程序时看不到我的按钮

iphone - 如何在 iOS 中创建不在 Unicode 中的下标字符

ios - Delphi:ARC 和 Objective-C 包装的对象 - 如何释放?

javascript - WebView 变白/空白

ios - 阻止 UIScrollView 滚动,如果滑动手势是在一个区域