Xcode for iPhone 中静态库和动态库的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3723856/
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
Difference between static and dynamic library in Xcode for iPhone
提问by prajakta
What is the difference between a static and dynamic library in XCode? And why doesn't Apple allow us to use dynamic libraries in our iOS applications?
XCode 中的静态库和动态库有什么区别?为什么 Apple 不允许我们在 iOS 应用程序中使用动态库?
回答by jer
While you can build dynamic libraries for Mac OS X, you cannot use them for iPhone development.
虽然您可以为 Mac OS X 构建动态库,但您不能将它们用于 iPhone 开发。
A static library is merely an archive of object files that gets pulled into a program linking against it. The linker will unarchive all the archive files, and pull them in during linking along with the rest of your object files.
静态库只是一个目标文件的存档,它被拉入一个链接到它的程序中。链接器将解压缩所有存档文件,并在链接期间将它们与其他目标文件一起拉入。
A dynamic library however, creates a shared object file, akin to a program but without an entry point, which programs can link against and call out of themselves into these shared libraries for their symbols, without pulling them into itself.
然而,动态库会创建一个共享对象文件,类似于程序但没有入口点,程序可以链接到这些共享库中并将其自身调用到这些共享库中以获取符号,而无需将它们拉入自身。
回答by skorulis
A dynamic library wouldn't make any sense for an iphone app as there is no way to install the library on the phone. I remember reading some documentation where apple stated they decided not to use dynamic libraries as they didn't want users to have to deal with hassles of finding/updating libraries. Much easier to just install 1 bundle per app.
动态库对于 iphone 应用程序没有任何意义,因为无法在手机上安装库。我记得读过一些文档,其中苹果表示他们决定不使用动态库,因为他们不希望用户不得不处理查找/更新库的麻烦。只需为每个应用安装 1 个捆绑包就容易多了。
回答by Paul Schreiber
Apple does allow you to make dynamic libraries. On Mac OS X, these end in .bundle or .dylib (not .so or .a like on Linux).
Apple 确实允许您制作动态库。在 Mac OS X 上,它们以 .bundle 或 .dylib 结尾(而不是像 Linux 上的 .so 或 .a)。
What, specifically are you trying to do? Did you create a target for your dylib?
什么,具体是你想做什么?您是否为 dylib 创建了目标?