[Haskell-cafe] Foreign function Intf./GHC newbie question

Bulat Ziganshin bulatz at HotPOP.com
Sat Nov 26 04:27:35 EST 2005

Hello John,

Saturday, November 26, 2005, 5:59:41 AM, you wrote:

JZ> I want to compile a Haskell program that calls a foreign C function.  I'm
JZ> using GHC.  When GHC links, it says it can't find my C function.  That is 
JZ> not surprising, because I can't figure out how I'm supposed to tell GHC 
JZ> where to find my C function.

in order to link in C module you should compile it separatelly (better
by ghc itself - it will setup all needed options and then call gcc)
and add its .o module to the cmdline: 

ghc -c myc.c
ghc --make ffi.hs myc.o

also try the following:

ghc --make ffi.hs myc.c

may be it will also work

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell-Cafe mailing list