[Haskell-cafe] Shared library creating on Mac OS X
pbeadling at mail2web.com
Sat Jan 10 12:17:29 EST 2009
I¹ve made a bit of progress here after reading up on Darwin¹s GCC a bit
ghc --make -no-hs-main -fPIC -optl '-dynamiclib' -optl '-undefined' -optl
'suppress' -optl '-flat_namespace' -o Inv.dylib InverseNormal.hs
This dies when it links against haskell¹s own libraries, my guess is because
they are position dependant. So the only way I see forward would be to
recompile haskell with ³fPIC².
This seems like a lot of hassle, so I¹m shelving this for now if anyone
has any other (less distruptive) ways to proceed give me a shout even if
it means linking statically.
Linker error now is:
ld: warning codegen with reference kind 13 in _stg_CAF_BLACKHOLE_info
prevents image from loading in dyld shared cache
ld: absolute addressing (perhaps -mdynamic-no-pic) used in
0.a(Array__1.o) not allowed in slidable image
collect2: ld returned 1 exit status
On 10/01/2009 02:26, "Phil" <pbeadling at mail2web.com> wrote:
> I¹m hitting a problem trying create shared haskell libs to be linked into a C
> program on Mac OS X.
> I¹m using the latest download for Leopard from the GHC page:
> I can get basic executables working fine (with a C main() #including ghc¹s
> stub header), using something like:
> ghc -optc-O invnorm.c InverseNormal.o InverseNormal_stub.o -o cTest
> I started off using the following line to try to create a shared lib:
> ghc --make -no-hs-main -optl '-shared' -o Inv.so InverseNormal.hs
> This doesn¹t work on mac os x because Apple¹s gcc annoyingly takes different
> switches, so I changed it to:
> ghc --make -no-hs-main -optl '-dynamiclib' -o Inv.dylib InverseNormal.hs
> Which still fails at the final link giving:
> Linking Inv.dylib ...
> Undefined symbols:
> "_environ", referenced from:
> _environ$non_lazy_ptr in libHSbase-188.8.131.52.a(PrelIOUtils.o)
> ld: symbol(s) not found
> I¹ve seen similar things before, and I believe if you have full control over
> the source you just slip in a:
> #define environ (*_NSGetEnviron())
> Sure enough, I can find references to environ in, for example HsBase.h
> Problem (as I see it) is that references to environ are already wrapped up in
> the static lib libHSbase-184.108.40.206.a, so without recompiling Haskell we can¹t
> alter the C definition now. However, given that packager must have made this
> behave when he compiled the distribution there must be a way to make Mac gcc
> accept _envrion symbols??
> Has anyone seen this before / can confirm my analysis / and by any chance have
> a solution?
> Many thanks,
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe