<p>Why does Leopard mangle some symbols with $non_lazy_ptr?  More importantly what is the best method to fix undefined symbol errors because a symbol has been mangled with $non_lazy_ptr?</p>

[{'answer_id': 79951, 'author': 'Brian Mitchell', 'author_id': 13716, 'author_profile': 'https://Stackoverflow.com/users/13716', 'pm_score': 3, 'selected': False, 'text': '<p>From: <a href="http://developer.apple.com/library/mac/#documentation/developertools/conceptual/MachOTopics/1-Articles/indirect_addressing.html#//apple_ref/doc/uid/TP40004919-SW1" rel="nofollow noreferrer">Developer Connection - Indirect Addressing</a></p>\n\n<p>Indirect addressing is the name of the code generation technique that allows symbols defined in one file to be referenced from another file, without requiring the referencing file to have explicit knowledge of the layout of the file that defines the symbol. Therefore, the defining file can be modified independently of the referencing file. Indirect addressing minimizes the number of locations that must be modified by the dynamic linker, which facilitates code sharing and improves performance.</p>\n\n<p>When a file uses data that is defined in another file, it creates symbol references. A symbol reference identifies the file from which a symbol is imported and the referenced symbol. There are two types of symbol references: nonlazy and lazy.</p>\n\n<p>Nonlazy symbol references are resolved (bound to their definitions) by the dynamic linker when a module is loaded.\nA nonlazy symbol reference is essentially a symbol pointer—a pointer-sized piece of data. The compiler generates nonlazy symbol references for data symbols or function addresses.</p>\n\n<p>Lazy symbol references are resolved by the dynamic linker the first time they are used (not at load time). Subsequent calls to the referenced symbol jump directly to the symbol’s definition.\nLazy symbol references are made up of a symbol pointer and a symbol stub, a small amount of code that directly dereferences and jumps through the symbol pointer. The compiler generates lazy symbol references when it encounters a call to a function defined in another file.</p>\n'}, {'answer_id': 290199, 'author': 'Vladimir Panteleev', 'author_id': 21501, 'author_profile': 'https://Stackoverflow.com/users/21501', 'pm_score': 2, 'selected': False, 'text': "<p>In human-speak: the compiler generates stubs with $non_lazy_ptr appended to them to speed up linking. You're probably seeing that function Foo referenced from _Foo$non_lazy_ptr is undefined, or something like that - these are not the same thing. Make sure that the symbol is actually declared and exported in the object files/libraries you're linking your app to. At least that was my problem, I also thought it's a weird linker thing until I found that my problem was elsewhere - there are several other possible causes found on Google.</p>\n"}, {'answer_id': 1055687, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>ranlib -c on your library file fixes the problem</p>\n'}, {'answer_id': 3062322, 'author': 'Ciryon', 'author_id': 22012, 'author_profile': 'https://Stackoverflow.com/users/22012', 'pm_score': 1, 'selected': False, 'text': '<p>If someone else stumbles the same problem I had: </p>\n\n<p>Had a <code>extern NSString* const someString;</code> in the header file, but forgot to put it the implementation file. as <code>NSString* const someString=@"someString";</code></p>\n\n<p>This solved it.</p>\n'}, {'answer_id': 3462790, 'author': 'Tom S.', 'author_id': 393049, 'author_profile': 'https://Stackoverflow.com/users/393049', 'pm_score': 2, 'selected': False, 'text': '<pre><code>ranlib -c libwhatever.a\n</code></pre>\n\n<p>is a solid fix for the issue. I had the same problem when building the PJSIP library for iOS. This library sort-of uses an autoconf based make system, but needs a little tweaking to various files to make everything alright for iOS. In the process of doing that I managed to remove the ranlib line in the rule for libraries and then started getting an error in the link of my project about <code>_PJ_NO_MEMORY_EXCEPTION</code> referenced from <code>_PJ_NO_MEMORY_EXCEPTION$non_lazy_ptr</code> being undefined.</p>\n\n<p>Adding the ranlib line back to the library file solved it.  Now my full entry for LIBS in rules.mak is</p>\n\n<pre><code>$(LIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)\n    if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi\n    $(LIBTOOL) -o $(LIB) $(OBJS)\n    $(RANLIB) -c $(LIB)\n</code></pre>\n\n<p>Hope this helps others as well trying to use general UNIX configured external libraries with iPhone or iOS.</p>\n'}]
['https://Stackoverflow.com/questions/79054', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']