The Hugs 98 User's Guide
Prev | Chapter 3. Changing the behaviour of Hugs | Next

# 3.4. Compiling modules that use the Foreign Function Interface

ffihugs [`+G`] [`option`...] [`+L` `cc-option`...] `file`

Suppose you have some C functions in `test.c` and some ffi declarations for those functions in `Test.hs` and the code in `test.c` needs to be compiled with `-lm`. To use these with Hugs, you must first use ffihugs to generate `Test.c`, compile it and link it against `test.c` with `-lm` to produce `Test.so`:

      ffihugs +G +L"test.c" +L"-lm" Test.hs

(If `Test.hs` depends on other ffi modules, you'll have to compile them first.) Now you can run Hugs as normal; when `Test.hs` is loaded, Hugs will load `Test.so`.)

      hugs Test.hs

and then use the imported or exported functions.

Prev | Home | Next
Standalone programs | Up | Hugs vs Haskell 98 and addenda