<p>There seem to be 3 ways of telling GCC to weak link a symbol:</p>

<ul>
<li><code>__attribute__((weak_import))</code></li>
<li><code>__attribute__((weak))</code></li>
<li><code>#pragma weak symbol_name</code></li>
</ul>

<p>None of these work for me:</p>

<pre><code>#pragma weak asdf
extern void asdf(void) __attribute__((weak_import, weak));
...
{
    if(asdf != NULL) asdf();
}
</code></pre>

<p>I always get a link error like this:</p>

<pre>Undefined symbols:
  "_asdf", referenced from:
      _asdf$non_lazy_ptr in ccFA05kN.o
ld: symbol(s) not found
collect2: ld returned 1 exit status</pre>

<p>I am using GCC 4.0.1 on OS X 10.5.5. What am I doing wrong?</p>

From the gcc doc manual:
weak
The weak attribute causes the declaration to be emitted as a weak
  symbol rather than a global.  This is primarily useful in defining
  library functions which can be overridden in user code, though it
  can also be used with non-function declarations.  Weak symbols are
  supported for ELF targets, and also for a.out targets when using
  the GNU assembler and linker.
which means that an object is legitimated to overwrite a weak symbol (defined in another object/library) without getting errors at link time. What is unclear is whether you are linking the library with the
weak
symbol or not. It's seems that both you have not defined the symbol and the library is not properly linked.