[Haskell-cafe] OSX, ghci, dylib, what is the correct way?

Brandon Allbery allbery.b at gmail.com
Sun Jun 12 20:45:26 CEST 2011

On Sun, Jun 12, 2011 at 14:31, Jason Dagit <dagitj at gmail.com> wrote:
> If I build the C library as a .a, then ghci comlains that it cannot
> open the .dylib.  My first question is: Why does ghci need a .dylib
> and does it really use it?

Static libraries are... static.  ghci would have to rebuild itself
against the static archive to use it; that's how static archives work.
 Dynamic libraries are dynamic because they can be loaded at runtime
instead of compile time.

> When I build a dylib I get a [segfault when loading the code into ghci][2].

I believe ghci still uses its own dynamic loader instead of the
standard library one, and as such it doesn't handle everything quite
correctly; Mach-O is a moving target and Apple doesn't always document
its changes.[1]  When you compile, the system linker is used to build
the executable and things work properly.

[1] http://hackage.haskell.org/trac/ghc/ticket/4244

More information about the Haskell-Cafe mailing list