[Haskell-cafe] Re: Resolved: ffi linking problem

Stefan O'Rear stefanor at cox.net
Fri Jun 1 22:21:18 EDT 2007

On Fri, Jun 01, 2007 at 10:10:53PM -0400, jeff p wrote:
> Hello,
> >If -fvia-C fixes your problem, then your code has a bug, strictly 
> >speaking.  If
> >your foreign call requires some information from a header file, then the 
> >right
> >way to call it is by making a small C wrapper function and calling that.
> >
> I tried to do this but couldn't. I could get GHC to compile and link
> with warnings of the form:
>    Warning: resolving _my_fun at 24 by linking to _my_fun
> But when I ran the executable, the system crashed at the point that a
> foreign function was called.
> >Bear in mind that we'll be deprecating -fvia-C in the future, and also 
> >that you
> >might want your code to work in GHCi too, which doesn't read any header 
> >files
> >when compiling foreign imports.
> >
> I am currently developing on a windows xp machine. After a week of
> fighting with FFI, I feel forced to conclude that FFI barely works
> with GHC (and seems to require -fvia-C) and doesn't work at all with
> GHCi (I think there is an unresolved bug about this). Am I wrong about
> the state of affairs for windows?

No, it sounds like you're using the wrong import syntax.

That linker warning is a dead givaway you should be using ccall, not


More information about the Haskell-Cafe mailing list