Creating Loadable Dynamic Libraries in OSX

Alfonso Acosta alfonso.acosta at
Tue Nov 21 22:32:17 EST 2006

Providing -fPIC (thanks Igloo :)) solves the "local relocation
entries" coming form the FFI stubs ...

... but uncovers yet a worse error. Now I get the "local relocation
entries" from libHStemplate-haskell.a .

Why doens't that library have position independent code?

A way to fix the error would be using the -dynamic flag, but for some
reason my OSX build doesn't have doesn't seem to have the dynamic

The concrete error is "ld: can't locate file for: -lHShaskell98_dyn"

On 11/22/06, Alfonso Acosta <alfonso.acosta at> wrote:
> Hi,
> I succesfully created dynamic loadable libraries (.so) with GHC6.6
> under LinuxX86 using some C glue code and linking with -optl -shared.
> Now I would like to port my code to OSX but linking with "-optl
> -bunde" fails giving a "local relocation entries in non-writable
> section" error.
> I think that is becase under OSX, GHC calls gcc with -mdynamic-no-pic
> preventing my FFI stub object files to be linked.
> Does anyone know why is -mdynamic-no-pic used or a workaround?
> Thanks in advance,
> Alfonso Acosta

More information about the Glasgow-haskell-users mailing list