Ignoring undefined character in dynamic library from Xcode

I have a character referenced in the target Xcode dynamic library, but it is not defined there. I need this undefined character. This is because it will be compiled differently in each process that includes it (based on a specific compilation time).

The goal of a dynamic library in Xcode is that it is not connected because it contains a link to this symbol (which is not unexpected), but I know that this symbol will be available at runtime. I will compile this function for every target that the shared library is associated with.

I am trying to get the linker to mark this particular character for dynamic search at runtime.

I managed to bind it if I specify "- undefined dynamic_lookup" as one of the "other linker flags" in my Xcode project. The problem is that I do not want to go that far. I know that only 1 character should be undefined. I want all other characters to generate errors if they are left as undefined (I want to avoid errors in missed errors in most cases).

I found a variant of ld linker that seems to be doing what I need (with 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 get it to work. Whenever I specify "-U symbolName" or "-UsymbolName" in "Other Linker Flags", I still welcome this linker error:

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

I'm using -U incorrectly, maybe? Isn't that the option I need, or is it just not working as intended?

+6
source share
1 answer

Set -Wl,-undefined,dynamic_lookup to OTHER_LDFLAGS .

Link: Xcode link clang: create a dynamic structure (or dylib) do not embed dependencies

+2
source

Source: https://habr.com/ru/post/948007/


All Articles