
Hi, 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: http://www.haskell.org/ghc/dist/6.10.1/witten/ghc-6.10.1-powerpc-apple-darwi n.tar.bz2 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-4.0.0.0.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-4.0.0.0.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, Phil.