如何修复“是动态库,未添加到静态库"警告?静态、动态、quot

2023-09-06 09:27:43 作者:春日樱亭

我刚升级到Xcode 5.1,突然有新的警告:

I just upgraded to Xcode 5.1, and all of a sudden there is a new warning:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:文件:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libz.dylib是动态库,没有添加到静态库中

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library

产生此警告的目标是 cocos2d-iphone v2 静态库(而不是使用 cocos2d 模板,我创建了一个静态库).为了创建静态库,我所做的只是将 cocos2d 项目添加到我的工作区,让我的项目链接到 cocos2d 链接到的库,仅此而已.在此更新之前,这一切都运行良好,但现在有一个警告.

The target which generates this warning is the cocos2d-iphone v2 static library (rather than use cocos2d templates, I create a static library). To create the static library all I did was add the cocos2d project to my workspace, have my project link to the libraries that cocos2d links to, and thats it. This all worked fine prior to this update, but now there is a warning.

我该如何解决这个问题?我不想乱搞cocos2d项目,因为有些项目我使用cocos2d模板而不是静态库.

How do I fix this ? I do not want to mess with the cocos2d project, because there are some projects in which I use the cocos2d template and not the static library.

推荐答案

静态库目标无法链接到 dylib.以前,这被简单地忽略了.您需要从静态库目标中删除所述 dylib,如有必要,将其添加到构建实际应用程序的每个目标中.

Static library targets can not link against dylibs. Previously this was simply ignored. You need to remove said dylib from the static library target and, if necessary, add it to each target that is building the actual app.

查看带有库构建阶段的链接二进制文件.了解 cocos2d 后,您可能需要从 cocos2d 目标的构建设置中删除其他链接器标志-lz".

Look into the Link Binary with Libraries Build Phase. Knowing cocos2d there's probably an Other Linker Flag "-lz" that you need to remove from Build Settings of the cocos2d target.