ffi - How to Use Haskell's Stack Build Tool to Export a Library to Be Consumed by C/C++? -
suppose 1 using stack
build tool make haskell library (importing packages hackage, , forth) to used c/c++ project in main
located in c/c++.
supposing project named lib.hs
(which uses external libraries hackage), there way use stack export lib.o
, lib.hi
, , lib_stub.h
consumed c/c++ compiler gcc
or g++
?
edit: related question might be: "how can 1 use stack build tool used haskell & c/c++ project in main
located in c/c++?
edit2: upon reflection, 1 way solve problem use stack usual, migrate c/c++ main function haskell. best way it? there huge performance costs or should aware of?
stack can't on own.
there's support generating called "foreign libraries" added cabal, it's not in released version, yet. see commit 382143 produce shared library dynamically links against dynamic versions of each haskell package used.
you can build package stack , after fact can assemble single native library. in galua project custom setup.hs , separate linking script.
the result of linking process standalone statically linked library suitable inclusion in c project: libgalua.a
.
do note creating standalone libraries on linux suitable being linked shared library you'll need recompile ghc generate pic static libraries (macos default).
Comments
Post a Comment