[Haskell-cafe] Creating DLLs with GHC

SevenThunders mattcbro at earthlink.net
Wed Sep 27 11:53:20 EDT 2006

Well I tried this statement
ghc --mk-dll -fglasgow-exts -fffi -I. --make ExternLib.hs

It only compiled the object file, creating ExternLib.o, but it did not
create the stub file or attempt to link in the dependent packages.  I then
went back to this,

ghc --mk-dll -fglasgow-exts -fffi -o netsim.dll ExternLib.o ExternLib_stub.o
dllNet.o src1.o src1_stub.o src2.o -package parsec -optl-lmatrixstack

This removed the undefined references to the parsec package, however I still
can't get it to link to the matrixstack.lib and matrixstack.dll. 
matrixstack.lib was created using dlltool and does link just fine if linking
the sources into a stand alone executable instead of a .dll.  I did try to
include matrixstack.lib on the command line directly as well but that ended
up with the same problem.

Is it possible to just compile everything into C?  I'd need to link to the
haskell runtime libraries somehow.

Esa Ilari Vuokko wrote:
> Hi
> On 9/27/06, Matthew Bromberg <mattcbro at earthlink.net> wrote:
>> though I have a binary build of ghc 6.5
> If you have new ghc 6.5, you can use --mk-dll with --make, in case that
> helps.
>> ghc --mk-dll -o netsim.dll ExternLib.o ExternLib_stub.o dllNet.o src1.o
>> src1_stub.o src2.o  -optl-lmatrixstack -optl-L"."
>> My external C library is in matrixstack.dll and it has a corresponding
>> static link stub library matrixstack.lib in the same directory as all
>> the sources. It has references in one of the sources (say src1.hs).
> If I recall correctly, to link Ms-style import libs, you must specify
> them as object
> files (ie no -optl-lfoo, but just foo.lib) or make mingw-style import
> libs via .def
> files.  But as you've not run into this yet, maybe it works for you like
> that.
>> Unfortunately I get a host of undefined references to basically all the
>> functions in matrixstack.dll and also some undefined references of the
>> form
>> Parsefile.o:ghc2996_0.hc:(.text+0x130): undefined reference to
>> `TextziParserCombinatorsziParsecziError_show_closure'
>> Parsefile.o:ghc2996_0.hc:(.text+0x220): undefined reference to
>> `TextziParserCombinatorsziParsecziChar_spaces_closure'
>> Parsefile.o:ghc2996_0.hc:(.text+0x24a): undefined reference to
>> `TextziParserCombinatorsziParsecziChar_spaces_closure'
>> Parsefile.o:ghc2996_0.hc:(.text+0x29c): undefined reference to
>> `TextziParserCombinatorsziParsecziChar_spaces_closure'
> Add
> -package parsec
> to you ghc commandline.  And similary for any other packages you used
> while
> compiling.
> HTH,
> Esa
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

View this message in context: http://www.nabble.com/Creating-DLLs-with-GHC-tf2342692.html#a6529535
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list