Take the 2-minute tour ×

I have a symbol that is being referenced in an Xcode dynamic library target, but it is not defined there. I NEED this symbol to be undefined. This is because it will be compiled differently in each process that includes it (based upon some compile time defines).

The dynamic library target in Xcode that fails to link because it contains a reference to this symbol (which is not unexpected), but I know that the symbol will be available at run time. I will be compiling this function into each target that the common library is linked to.

I am trying to get the linker to mark this particular symbol for dynamic lookup at run time.

I have been able to get it to link if I specify "-undefined dynamic_lookup" as one of the "Other Linker Flags" in my Xcode project. The problem is that I don't want to go that far. I know that only 1 symbol is supposed to be undefined. I want all the rest of the symbols to generate errors if they are left as undefined (I want to avoid a run time missing symbol error basically).

I found a ld linker option that seems like it should do what I need (from ld man page):

-U symbol_name
             Specified that it is ok for symbol_name to have no definition.  With -two_levelnamespace, the resulting symbol will be marked dynamic_lookup which means dyld will search all loaded images.

However, I cannot seem to get it to work. Whenever I specify "-U symbolName" or "-UsymbolName" in the "Other Linker Flags" I am still greeted with this linker error:

Undefined symbols for architecture x86_64:
     "_symbolName", referenced from: <various object files>

Am I using -U incorrectly perhaps? Is it not really the option I need, or is it just not working like it is supposed too?

share|improve this question
Doesn't --unresolved-symbols=ignore-all work for you? –  devnull Jun 28 '13 at 13:39
@devnull I didn't try that, but I got the equivalent behavior (ignoring all resolved symbols) from "-undefined dynamic_lookup". The problem is, going forward I don't want all undefined symbols ignored. I just want one ignored. I don't want to have to ignore all of them just to ignore this one. –  John Bowers Jun 28 '13 at 15:21
I could be wrong, but shouldn't you be specifying -U _symbolName? –  Brad Allred Oct 28 '13 at 16:22

Your Answer



Browse other questions tagged or ask your own question.