One of the libraries that makes up my application depends on -undefined dynamic_lookup
to link, and has since at least Snow Leopard if not earlier. I think iOS hasn't liked this for a while, but with the new linker I'm getting deprecation warnings even on OS X. I don't entirely understand what this flag does, other than it makes the build successful. :) So I'm at a loss on how to even approach fixing it. At this point, even links to useful resources would be appreciated, since googling hasn't yielded much beyond "remove -undefined
to quiet the deprecation warning."
FWIW, there is a bit of circular dependence between this library and another. On another OS, we need a carefully choreographed dance of building object files, then import libraries, then final linking to make this all work. So I suspect this may be related, but even if I'm correct, I don't know what would be the equivalent tools on Apple platforms.
This flag controls how the linker responds to undefined symbols. The canonical documentation for it is the ld
man page, but it’s hard to understand that without some background. To start, I recommend that you read through the discussion of the two-level namespace and stub libraries in An Apple Library Primer.
Enabling dynamic_lookup
mode tells the linker to allow all undefined symbols on the assumption that they will be resolved by the dynamic linker at runtime. That means that the linker can’t record the library in which the symbol should be found, which defeats the two-level namespace. At runtime the dynamic linker resolves such a symbol by searching all libraries. That’s both slow and risky, in that you might not get the symbol you want.
You’re not the first person to hit that. See this thread. Note that the recommended reply has a comment with a link to even more info.
That’s certainly a challenge [1]. In many cases you can fix that by deploying stub libraries, but the devil in the details. If you post more info about your issue, I should be able to offer specific guidance.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] IMO it’s also a code smell. Your library dependencies should form an acyclic graph. Allowing cycles introduces all sorts of complexity, for example, it opens you up to cycle initialisation issues at runtime. In most cases the correct fix to this problem is to refactor your code to get rid of the cycle.