[Haskell-cafe] Re: FFI question
Simon Marlow
simonmarhaskell at gmail.com
Thu Feb 9 06:44:16 EST 2006
Frederico Franzosi wrote:
> I'll try to make it short.
>
> I'm developping a package wich imports C functions.
>
> the fact is that when I try to compile if I call the compiler in the
> usual way, using -package and -llib it gives an undefined reference
> error...
>
> For example if I use:
> $ghc -package PKGname-PKGversion -fffi -o main Main.hs -llib
>
> it gives an error message (undefined references of objects from PKG to
> functions in lib)
>
>
> but if I use:
>
> $ghc -fffi -o main Main.hs -llib /path/to/PKGlib.a
>
> it compiles correctly.
It looks like -llib is appearing earlier on the linker's command line
than the library from your package, when you use -package. You haven't
specified a dependency between the two, so GHC is making an arbitrary
choice.
The right way to fix this, if your package depends on a library, is to
include that library in the "extra-libraries" field of the package.
Cheers,
SImon
More information about the Haskell-Cafe
mailing list