Ghci dynamic linking (Was: C++ libraries and GHCI)

C Rodrigues red5_2 at
Thu Oct 8 09:46:08 EDT 2009

I've encountered the problem with weak symbols also, and filed a bug report against ghc (#3333).
Weak symbols are used by gcc (with elf) to accommodate C++'s compilation model.  In C++, it's permitted to define class methods and template code in header files.  Because header files can be included in many source files, the same object code will appear in many object files.  It's the linker's job to merge these definitions.  There's no standard way of handling C++ linking, unfortunately, so handling weak symbols won't necessarily solve the problem for every compiler.
If there will be no cross-references involving weak symbols between different .a files, such as when you have a C++ library that doesn't depend on other C++ libraries, then it should be sufficient to treat a weak defined symbol as 'defined' and a weak undefined symbol as NULL.  However, I don't know if this is really a common case; most C++ code depends on libstdc++, in which case there may be multiple weak symbol definitions.
> Thanks for the reply, Max.
> If it's not something overly complex, I'll try to hack ghc
> to see if I can produce a working patch...
> probably that symbol type can be safely ignored by
> ghci linker.
> Thanks again for your help
> Paolo
> On Wed, Sep 30, 2009 at 2:29 PM, Max Bolingbroke
> <batterseapower at> wrote:
> > (Moving to ghc-users)
> >
> > I'd never seen V in nm output before:
> >
> > """
> > The symbol is a weak object.  When a weak defined symbol is linked
> > with a normal defined symbol, the normal defined symbol is used with
> > no error.  When a weak undefined symbol is linked and the symbol is
> > not defined, the value of the  weak symbol becomes zero with no error.
> >  On some systems, uppercase indicates that a default value has been
> > specified.
> > """"
Hotmail: Trusted email with powerful SPAM protection.
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list