ios libz.dylib 与 libz.1.2.3.dylib 与 libz.1.2.5.dylib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6932991/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libz.dylib versus libz.1.2.3.dylib versus libz.1.2.5.dylib
提问by Hyperbole
I asked this in a comment but this seems like an issue that deserves its own question.
我在评论中提出了这个问题,但这似乎是一个值得自己提出问题的问题。
I have a project that's shared between three different installations of XCode and two different installations of the iOS SDK. At the moment unifying the developers involved is not an option.
我有一个在三个不同的 XCode 安装和两个不同的 iOS SDK 安装之间共享的项目。目前,统一所涉及的开发人员不是一种选择。
When I installed the iOS 5 Beta and XCode 4.2 libz.1.2.3.dylib
was nowhere to be found. I discovered that linking against libz.1.2.5.dylib
handled this but this was not compatible with the other active installations of XCode and the iOS SDK.
当我安装 iOS 5 Beta 时,libz.1.2.3.dylib
找不到XCode 4.2 。我发现链接libz.1.2.5.dylib
处理了这个问题,但这与 XCode 和 iOS SDK 的其他活动安装不兼容。
I researched this online and discovered the above suggestion and thissuggestion. The former doesn't work for me, and the latter makes me nervous.
我在网上研究了这个,发现了上面的建议和这个建议。前者不适合我,后者让我紧张。
So what's the difference between libz.dylib
, libz.1.2.3.dylib
and libz.1.2.5.dylib
and can I safely link to the first across all installations of XCode and the iOS SDK?
那么,有什么之间的区别libz.dylib
,libz.1.2.3.dylib
并libz.1.2.5.dylib
和我能安全地跨越Xcode和iOS SDK中的所有安装链接到第一张?
采纳答案by epatel
The OS often includes many versions of dynamic libraries. These are used by different programs depending on which library they were compiled against at their compile time, but when you compile you want to link against the version that correspond to the installed headers which you are including/importing into your source code.
操作系统通常包括许多版本的动态库。这些由不同的程序使用,具体取决于它们在编译时针对哪个库进行编译,但是当您编译时,您希望链接与您要包含/导入到源代码中的已安装头文件对应的版本。
The libz.dylib
will be a link to the same version that your installed headers use.
这libz.dylib
将是指向您安装的标头使用的相同版本的链接。
Say you have 2 versions libXYZ.1.dylib
and libXYZ.2.dylib
, libXYZ.dylib
is a link to libXYZ.2.dylib
and libXYZ.1.dylib
is a legacy lib that is also available in the OS for apps compiled and distributed before libXYZ.2.dylib
was released. The libXYZ.1.dylib
has been included in the SDK because there can be old frameworks that still want to be linked against the old version.
假设你有2个版本libXYZ.1.dylib
和libXYZ.2.dylib
,libXYZ.dylib
是一个链接libXYZ.2.dylib
,并libXYZ.1.dylib
是一个遗留LIB,这也是在为OS编发之前的应用程序可libXYZ.2.dylib
被释放。在libXYZ.1.dylib
已包含在SDK中,因为有可能是仍然要对旧版本中联旧框架。
The two versions might have very similar interfaces in the header so you won't see any real differences when you compile and run, but in future versions the older versions might get removed and new ones added which will make your project break when linking.
这两个版本的头文件中可能有非常相似的接口,因此您在编译和运行时不会看到任何真正的差异,但在未来的版本中,旧版本可能会被删除并添加新版本,这将使您的项目在链接时中断。
If I understand it right, the linker will dereference file links so it will find the right version and keep that dylib name and dynamically link against that when the app starts. So the libz.dylib
won't be the path used (more than at compile time).
如果我理解正确,链接器将取消引用文件链接,以便找到正确的版本并保留该 dylib 名称并在应用程序启动时动态链接该名称。所以libz.dylib
不会是使用的路径(比编译时更多)。
I see this in my Xcode installation in the 4.3 SDK
我在 4.3 SDK 的 Xcode 安装中看到了这一点
/Developer/.../SDKs/iPhoneOS4.3.sdk/usr/include/zlib.h
/Developer/.../SDKs/iPhoneOS4.3.sdk/usr/include/zlib.h
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.3, July 18th, 2005
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
libz.dylib
动态库
/Developer/.../SDKs/iPhoneOS4.3.sdk/usr/lib/libz.dylib -> libz.1.2.3.dylib
回答by Simon Woodside
You can easily see in the finder how they work. In XCode, "Show in Finder" one of the libraries. Now click once on libz.dylib and "Get Info". You'll see that "Original" is:
您可以在取景器中轻松查看它们的工作方式。在 XCode 中,“在 Finder 中显示”库之一。现在单击一次 libz.dylib 和“获取信息”。你会看到“原始”是:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libz.1.2.5.dylib
(as of XCode4.2 with iOS 5 SDK)
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libz.1.2.5.dylib
(从带有 iOS 5 SDK 的 XCode4.2 开始)
So it's a symbolic link to version 1.2.5 for now. In the future it will update to the latest 1.x.x. You can examine all of the various versions this way.
所以它现在是 1.2.5 版的符号链接。将来它会更新到最新的 1.xx 您可以通过这种方式检查所有不同的版本。
回答by Farooq Nasim Ahmad
Just link with libz.dylibinstead of a specific version and compiler will link the available version on installed SDK. Linker error may come in case of linking with some specific version that is not available in currently installed SDK.
只需链接libz.dylib而不是特定版本,编译器将链接已安装 SDK 上的可用版本。如果链接到当前安装的 SDK 中不可用的某些特定版本,则可能会出现链接器错误。
回答by Akram Khan
You can use use libz.1.2.5.dylib instead of libz.1.2.3.dylib
您可以使用 libz.1.2.5.dylib 而不是 libz.1.2.3.dylib
Replace libz.1.2.3.dylib -----> libz.1.2.5.dylib
替换 libz.1.2.3.dylib -----> libz.1.2.5.dylib