Kategorie

Nejnovější článek

Archiv

Odkazy


Hledání




Building a shared library in Haskell

A lot has been written on the topic of Foreign Function Interface and its use for calling Haskell from C, yet the official GHC and FFI documentation lack a description of an easy way to create a shared library that may be used from C in a regular way. In this article I present a little bit hacky, but still very simple and comfortable way to do this on Linux (which hopefully applies to all similar Unixes as well).

The FFI documentation as well as the GHC manual explain that you have to call hs_init before calling into Haskell. I will present a C helper that does this automatically, I shall explain why it really works and I will provide a Makefile that makes this all pretty easy. In the end, we're going to be able to simply write Haskell modules with a few foreign export declarations and get working shared libraries out of the box. Pokračování »

Autor: Tomáš Janoušek Kategorie: haskell Dva komentáře » Prosinec 2008