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?
Asked
Active
Viewed 250 times
4

brandizzi
- 26,083
- 8
- 103
- 158
-
iphone-sdk allows linking dynamic libraries ? (I'm not sure ...) – Mihir Mehta Nov 18 '11 at 10:51
-
1@mihirmehta: Cocoa is present on Macs as well. – mouviciel Nov 18 '11 at 11:13
-
1And the cocoa tag is for questions about Cocoa on Mac OS X. For iOS, Apple uses the phrase Cocoa Touch and the corresponding Stack Overflow tag is cocoa-touch. – Nov 18 '11 at 11:15
3 Answers
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

yoAlex5
- 29,217
- 8
- 193
- 205
-1
iOS app should NOT have any dynamic libraries. Your only option is to statically link code.

Aditya Kumar Pandey
- 991
- 8
- 11
-
-1: This question is about Cocoa, and Cocoa applications can certainly use dynamic libraries. – Nov 18 '11 at 11:13
-