<div>After a several-month hiatus, I've returned to working on my main LLVM project. However, after checking out the latest LLVM head I'm encountering a new problem. When I attempt to load my custom plugin pass into opt, I'm getting this error message:</div>

<div><br></div><div>dyld: lazy symbol binding failed: Symbol not found: __ZN4llvm2cl3optIbLb0ENS0_6parserIbEEE4doneEv</div><div>  Referenced from: /Users/talin/Projects/tart/build-eclipse/linker/libgc.dylib</div><div>  Expected in: flat namespace</div>

<div><br></div><div>It appears to be due to the fact that I'm using LLVM's command-line functions from within my plugin:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><p class="p1"><font face="'courier new', monospace">cl::<span class="s2">opt</span><<span class="s1">bool</span>> optShowGC(<span class="s3">"show-</span><span class="s4">gc</span><span class="s3">"</span>,<span class="s5"> cl::desc(</span>"Print debugging output from GC strategy"<span class="s5">));</span></font></p>

</div></blockquote><div>(when I remove the option from the source, everything works fine.)</div><div><br></div><div>Now, I recognize the 'flat namespace' phrase from my build file, which passes "-<span class="s1">Wl </span>-flat_namespace -<span class="s1">Wl </span>-undefined -<span class="s1">Wl </span>suppress" to the linker when building the plugin. I remember that someone gave me this magic formula (or perhaps I got it off a search result) - I certainly don't understand what it means. I remember it had to do with creating the plugin in such a way as to resolve undefined symbols against the main program when loaded, instead of giving an error for each undefined symbol. (This appears to be specific to OS X, the linker on Linux doesn't require these flags.)</div>

<div><br></div><div>A more general question is this - I've never really found a good reference or tutorial for building plugin libraries, in particular the kinds used with LLVM. I don't expect LLVM's docs to teach me how to compile and link a shared library, but it seems like there's a fair amount of non-obvious esoterica involved here, and it would be nice to have a pointer to some doc that would make it all less mysterious :)</div>

<div><br></div>-- <br>-- Talin<br>