Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell编译dll_Dll_Haskell - Fatal编程技术网

Haskell编译dll

Haskell编译dll,dll,haskell,Dll,Haskell,我需要为这个模块创建dll module MarketNews where import Foreign import Foreign.C.Types import Foreign.C.String import HighAPI(getNextNewsInfo) getNextNewsInfoM :: IO CString getNextNewsInfoM = getNextNewsInfo >>= \x -> newCString x foreign export st

我需要为这个模块创建dll

module MarketNews where
import Foreign
import Foreign.C.Types
import Foreign.C.String

import HighAPI(getNextNewsInfo)

getNextNewsInfoM :: IO CString
getNextNewsInfoM = getNextNewsInfo >>= \x -> newCString x

foreign export stdcall getNextNewsInfoM :: IO CString
我汇编:

 C:\Users\test_8\Documents\Project\MarketNews\src>ghc --make MarketNews.hs  -fglasgow
-exts
我还有dllMain.o,它创建了like和MyDef.def。然后我做下一步:

C:\Users\test_8\Documents\Project\MarketNews\src>ghc -shared -o MarketNews.dll M
arketNews.o MarketNews_stub.o dllMain.o MyDef.def
Creating library file: MarketNews.dll.a
Warning: resolving _getNextNewsInfoM by linking to _getNextNewsInfoM@0
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
MarketNews.o:fake:(.text+0x6b): undefined reference to `HighAPI_getNextNewsInfo_
closure'
MarketNews.o:fake:(.text+0x12d): undefined reference to `__stginit_HighAPI_'
MarketNews.o:fake:(.data+0x10): undefined reference to `HighAPI_getNextNewsInfo_
closure'
collect2: ld returned 1 exit status
据我所知,它失败了,因为必须有一个根模块。但是为什么我可以用外语?为什么我不能使用HighAPI模块?我应该把整个程序写在一个文件中吗?
谢谢。

GHC 6.12支持创建包含Haskell库及其所有依赖项(包括RTS)的单个DLL。它不能创建相互调用的Haskell代码的单独DLL,尽管该功能已经实现,并且可能在即将发布的GHC 6.14.1中提供


要回答您的问题,当您使用
ghc-shared
创建DLL时,还需要在
HighAPI
模块中链接。有关创建Haskell DLL的更多信息,请参阅(阅读本文,因为GHC用户指南中的信息在一些方面是错误的,特别是如何使用
DllMain
)。

谢谢。我读了这个博客。我没有看到如何创建链接到其他模块的DLL的示例。安东:您需要将库中的所有模块链接在一起。e、 g.
ghc-shared-o MarketNews.dll HighAPI.o MarketNews.o MarketNews_stub.o dllMain.o MyDef.def
。它不起作用,我会反复尝试。我得到了如下错误:HighAPI.o:false:(.text+0x14f):未定义对`\u stginit\u datetimezm0zi2\u D ataziDateTime\uz'collect2:ld返回了1个退出状态我认为它的错误来自Data.DateTime模块。我如何链接到它?成功。我找到了如何链接包:ghc-shared-o MarketNews.dll HighAPI.o MarketNews.o MarketNews_stub.o dllMain.o MyDef.def-package datetime