[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] FFI, C/C++ and undefined references

Subject: Re: [Haskell-cafe] FFI, C/C++ and undefined references
From: Daniel Fischer
Date: Thu, 14 Jan 2010 23:23:12 +0100
Am Donnerstag 14 Januar 2010 22:19:08 schrieb Miguel Mitrofanov:
> Works fine here (Mac OS X 10.5):
>
> MigMit:ngram MigMit$ ghc --make Main.hs srilm.o
> [1 of 2] Compiling LM               ( LM.hs, LM.o )
>
> LM.hs:9:0: Warning: possible missing & in foreign import of FunPtr
> [2 of 2] Compiling Main             ( Main.hs, Main.o )
> Linking Main ...

Thanks Miguel.
Yes, works here (openSuse 11.1), too (kind of):

(move the typedef out of the #else clause in srilm.h, because my g++ 
doesn't know Ngram)

$ g++ -c srilm.c
$ ghc --make Main.hs srilm.o
[1 of 2] Compiling LM               ( LM.hs, LM.o )                   

LM.hs:1:11:
    Warning: -#include is deprecated: No longer has any effect

LM.hs:13:0: Warning: possible missing & in foreign import of FunPtr
[2 of 2] Compiling Main             ( Main.hs, Main.o )            
Linking Main ...
$ ./Main                 
0.0                                                                
Speicherzugriffsfehler

Fixing the two warnings (removing the {-# INCLUDE #-} pragma and changing 
the declaration of deleteLM to
foreign import ccall "srilm.h &deleteLM" 
    c_dlm :: FunPtr ((Ptr Ngram) -> IO ())
), I get
$ ghc -fforce-recomp --make Main.hs srilm.o
[1 of 2] Compiling LM               ( LM.hs, LM.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )
Linking Main ...
$ ./Main
0.0
$

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>