4

I need to use a library in a Cocoa application and can use either a dynamic (.dynlib) or a static (.a) version of it. I came from Linux world and would happily use the dynlib. However, since the app bundle will contain all the dependencies (including the dynlib) I thought it would not be a problem to have a bigger binary due to the static linking. What is the best solution?

brandizzi
  • 26,083
  • 8
  • 103
  • 158

3 Answers3

3

In this case, my concern would be responsiveness with respect to loading time of big executable vs. small executable and multiple libraries. The difference may be small.

mouviciel
  • 66,855
  • 13
  • 106
  • 140
  • Well, I am assuming the standard in Mac OS is to put all dynamic libraries inside the bundle (`.app`) anyway, which would mean that the library would always be download, either as an extra file or inside the binary. Is my assumption wrong? – brandizzi Nov 18 '11 at 11:42
  • I don't mean the download time of the installation package from a remote server to the local hard disk drive. I mean the loading time of the executable from hard disk drive to RAM. – mouviciel Nov 18 '11 at 12:18
  • Oh, ok, I understand now. I could link statically any library that will be inevitably called, and link dynamically any library that _could_ be called, and probably the difference will be imperceptible. I am planning to use static linking then. – brandizzi Nov 18 '11 at 12:27
0

You cannot create a dynamic library .dylib but you are able to create a dynamic framework with .dylib inside. The answer depends on your needs

[iOS static vs dynamic library]

[Create Objective-C dynamic framework]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
-1

iOS app should NOT have any dynamic libraries. Your only option is to statically link code.