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

Simon Marlow simonmarhaskell at gmail.com
Thu May 31 07:13:04 EDT 2007


jeff p wrote:
>  In case anyone else finds this useful...
> 
>  My linking problem was finally resolved by using the -fvia-C flag
> when compiling with ghc.
> 
> Thanks to Stefan O'Rear who pointed out the possibility and wrote:
>>
>> Does using -fvia-C help at all?  The C compiler understands header
>> files and is sometimes better equipped to resolve things.

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.

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.

Cheers,
	Simon


More information about the Haskell-Cafe mailing list