<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.E-mailStijl18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.E-mailStijl19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>HI all,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I try to create a dll with ghc (ver 8.6.5)  on Windows 7 64 bits. I ‘am using the dll with loadLibrary in a cpp program in Visual Studio. I create the dll with: <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ghc Vogels.hs <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ghc -c StartEnd.c<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>ghc --make -static -shared -fPIC Vogels.o StartEnd.o -o Vogels.dll <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>StartEnd.o defines HsStart and HsEnd to initialize and close the Haskell runtime.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>This works. I can create the dll and use the dll in VS.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>But, if I replace in Vogels.hs the line b=True with   b <- doesFileExist vogelsFn, creating the dll fails with error message: <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Vogels.o:fake:(.text+0x35c): undefined reference to `directoryzm1zi3zi3zi2zmB9tglvOQ6L9Cf7zzVEJ1S6t_SystemziDirectory_doesFileExist_closure' <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Vogels.o:fake:(.text+0x37d): undefined reference to `directoryzm1zi3zi3zi2zmB9tglvOQ6L9Cf7zzVEJ1S6t_SystemziDirectory_doesFileExist_closure' <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Vogels.o:fake:(.data+0xd0): undefined reference to `directoryzm1zi3zi3zi2zmB9tglvOQ6L9Cf7zzVEJ1S6t_SystemziDirectory_doesFileExist_closure'  <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>It looks like GHC can’t find the Directory package. I’ve installed this package. What can I do about it and how can I find out  the dependencies in a *.hs or *.o file? Almost all documentation about dll’s is about Linux or about using dll’s in Haskell.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Kees  <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>                                                                                                                                            <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>{-# LANGUAGE BlockArguments #-}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>{-# LANGUAGE ForeignFunctionInterface #-}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>module Vogels (   <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>   loadVogels<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>) where <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>   <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>import System.Directory<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>import Foreign.Ptr<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>import Foreign.Storable<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>import Foreign.C.String<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>loadVogels :: String  -> IO (Either String String)<o:p></o:p></span></p><p class=MsoNormal>loadVogels vogelsFn = do<o:p></o:p></p><p class=MsoNormal>   -- b <- doesFileExist vogelsFn<o:p></o:p></p><p class=MsoNormal>    <span lang=EN-US>let b=True<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    if b <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    then return $ Left $ "Can\'t find " ++ vogelsFn<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>    else do <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            txt <- readFile vogelsFn<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            return $ Right txt<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>loadVogelsFFI :: Ptr Int -> CString -> IO CString <o:p></o:p></span></p><p class=MsoNormal>loadVogelsFFI messageKind vogelsFnFFI = do <o:p></o:p></p><p class=MsoNormal>   vogelsFn  <- peekCString vogelsFnFFI<o:p></o:p></p><p class=MsoNormal>   <span lang=EN-US>eitherRes <- loadVogels vogelsFn <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>   case eitherRes of <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>      Left errMsg -> do <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            poke messageKind 1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            newCString errMsg<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>      Right txt ->  do <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            poke messageKind 0<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>            newCString txt<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>foreign export ccall loadVogelsFFI :: Ptr Int -> CString -> IO CString<o:p></o:p></span></p></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virusvrij. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>                </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body></html>