[Haskell-cafe] ffi linking problem

Stefan O'Rear stefanor at cox.net
Tue May 29 23:13:54 EDT 2007


On Tue, May 29, 2007 at 11:09:15PM -0400, jeff p wrote:
> Hello,
> 
> On 5/29/07, Brandon S. Allbery KF8NH <allbery at ece.cmu.edu> wrote:
> >
> >On May 29, 2007, at 23:01 , jeff p wrote:
> >
> >>    myPrompt> ghc --make -fffi f.hs -l mylib.lib
> >
> >For historical reasons, you can't have a space between the -l and the
> >library name.  It's inserting an empty library name into the link
> >command, which is producing the odd "cannot find" error.
> >
> Ok. Now I get another error:
> 
>    myPrompt> ghc --make -fffi f.hs -lmylib.lib
>    ghc --make -fffi f.hs -lmylib.lib
>    Linking f.exe ...
>    d:\ghc\ghc6.6\gcc-lib\ld.exe: cannot find -lmylib.lib
>    collect2: ld returned 1 exit status
> 
> which is strange because the file mylib.lib is in the same directory
> as the haskell code.

Don't know about Windows, but on traditional Unix systems -l appends
an extension and prepands /library/path/lib, so -lc links
/lib/libc.so; if your library does not follow the naming conventions,
you must omit -l and directly reference ./foobarlib.so as a file to
link (GHC will link any object code files listed on the command line). 

Stefan


More information about the Haskell-Cafe mailing list