[Haskell-cafe] Shared library creating on Mac OS X
pbeadling at mail2web.com
Fri Jan 9 21:26:53 EST 2009
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 ...
"_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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe