[Haskell-cafe] [Haskell] Linker flags for foreign export.

Max Bolingbroke batterseapower at hotmail.com
Tue Mar 8 09:23:28 CET 2011


Hi Jason,

On 8 March 2011 05:28, Jason Dusek <jason.dusek at gmail.com> wrote:
>    gcc -g -Wall -O2 -fPIC -Wall -o import \
>      -I/usr/lib/ghc-6.12.1/include/ \
>      import.c exports.so

In my experience, the easiest way to do this is to use gcc to build
object files from C source files, and then specify those object files
on the ghc command line in order to get GHC to do the linking step.
This will deal with linking in the correct RTS and, if you specify
appropriate -package flags, dependent packages as well.

If you want a C main function then see user guide section 8.2.1.1 at
http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html.

Cheers,
Max



More information about the Haskell-Cafe mailing list