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

Jason Dagit dagitj at gmail.com
Sun Jun 12 21:17:57 CEST 2011

On Sun, Jun 12, 2011 at 11:45 AM, Brandon Allbery <allbery.b at gmail.com> wrote:
> 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.

Interesting.  When I use dtruss to see what files ghci opens, it
definitely opens .a files.  That gave me the impression it knows how
to open a .a and use it at run-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

It's hard for me to make sense of that ticket with so little context.
This comment seems to go against what you're saying:
Changed 10 months ago by igloo

milestone set to 6.16.1
The best way to achieve this is probably to switch to using dynamic
libraries for GHCi.


More information about the Haskell-Cafe mailing list