[Haskell] Importing things via the FFI?

ihope ihope127 at gmail.com
Mon May 29 20:06:08 EDT 2006


So I decided to pop into the FFI Report thing. I came up with this C
file (which may or not actually be valid C; I'm not a C guy), called
ffitest.h:

> int add(Int x, Int y) {
>   return x+y;
> }

And ffitest.hs:

> import Foreign.C.Types
>
> foreign import ccall "ffitest.h add" add :: CInt -> CInt -> CInt

Ye error message:

> During interactive linking, GHCi couldn't find the following symbol:
>   add
> This may be due to you not asking GHCi to load extra object files,
> archives or DLLs needed by your current session. (blah blah blah)

Obviously I'm doing something wrong here, but what is it?


More information about the Haskell mailing list