
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. "foreign import blah blah" just gives me undefined references.

2008/11/8 Nun Aurbiz
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. "foreign import blah blah" just gives me undefined references.
You need to give the libraries you are using on the command line just like gcc. ghc --make Foo -lbar Luke

Nun Aurbiz wrote:
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. "foreign import blah blah" just gives me undefined references.
I've documented some of manual building in an old post on FFI http://therning.org/magnus/archives/238 Not sure if it's enough to get you on your way though... /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus Haskell is an even 'redder' pill than Lisp or Scheme. -- PaulPotts

Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. "foreign import blah blah" just gives me undefined references.
One well documented and compiler independent way to do that is to use Cabal packages: http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html as used on Hackage: http://hackage.haskell.org If you have never done that, you will take some time to understand the role of the setup file (which in your case will problably be something like: import Distribution.Simple; main=defaultMain) and the details of .cabal files. (The problem you are concerned with is detailed in 3.1.4: Build Information. You'll see you can also list C files to be compiled with your code, and if you are using some library that implements the pkg-config standard then everything is really, really easy. I advise you to also understand well how 'build-depends' works and how to list language features out of Haskell 98 — in your situation, at least 'extensions: ForeignFunctionInterface'.) Best, Maurício
participants (4)
-
Luke Palmer
-
Magnus Therning
-
Mauricio
-
Nun Aurbiz