Example C program, showing to to call Haskell shared libraries. Also demonstrates how to build a dynamically- and statically-linked Haskell shared library.
$ make test
...
PASS
Entrée: A shared library with a pure Haskell centre, linked with dynamic Haskell libraries.
$ make dynamic-build
...
$ make dynamic-test
...
Testing dynamic flavour
Simple test: PASS
Threaded test: PASS
Plat principal: A shared library with a pure Haskell centre, linked with static Haskell libraries.
$ make static-build
...
$ make static-test
...
Testing static flavour
Simple test: PASS
Threaded test: PASS
Note: On Linux, the static flavour requires rebuilding GHC packages as position-independent code.
Made by Miëtek Bak. Published under the BSD license.
Thanks to Albert Lai for an illuminating series of articles, including “Calling Haskell Shared Libraries from C”.