
Thank you Simon...
That was just what I needed...
Short and simple.
I would like also to thank all for the answers. That will be surely
helpful too, if not for me, maybe for someone else.
On 2/9/06, Simon Marlow
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