[Haskell-cafe] Creating DLLs with GHC

Matthew Bromberg mattcbro at earthlink.net
Wed Sep 27 00:54:09 EDT 2006


I am having some difficulty with creating a dynamic link library using 
GHC on windows XP.

I am attempting to follow the example in
http://www.haskell.org/ghc/docs/6.4/html/users_guide/win32-dlls.html

though I have a binary build of ghc 6.5

My problem (I think) is that some of my Haskell source files link to an 
external C library also contained in a DLL.

I generate my Haskell object files when I compile my Haskell executable. 
I then attempt to use the object files in a ghc compiler statement like 
this,

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).

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'
...

This appears to be coming from unsatisfied references to 
Text.ParserCombinators.Parsec, which I thought was a standard library.  
I note that my stand alone haskell executable links just fine and runs 
perfectly.

What am I missing to make this work?




More information about the Haskell-Cafe mailing list