简体   繁体   English

Haskell - GHC中的问题编译

[英]Haskell - Issue Compiling in GHC

I'm very new to Haskell, and I've recently installed the platform with GHC. 我对Haskell很新,我最近用GHC安装了这个平台。 I decided to test it out by compiling a simple Hello world program: main = putStrLn "Hello, world" 我决定通过编译一个简单的Hello world程序来测试它: main = putStrLn "Hello, world"

Now, when I go into the command line (Windows 7), find the proper directory, and type in ghc hello.hs , it comes back with the following message: "[1 of 1] Compiling Main ( hello.hs, hello.o )". 现在,当我进入命令行(Windows 7),找到正确的目录,并输入ghc hello.hs ,它返回以下消息:“[1 of 1]编译Main(hello.hs,hello。 o)“。 I understand that once it's done compiling, it should follow with "Linking hello.exe ...", but that never comes, and no .exe is produced. 我知道,一旦完成编译,它应该跟随“链接hello.exe ...”,但这永远不会到来,并且没有.exe生成。

Basically, is there any discernible reason why this would be happening? 基本上,有没有明显的理由为什么会发生这种情况? Is there a problem with the code, is there something I don't know about, or should I just try re-installing the Haskell Platform? 代码有问题,有什么我不知道的,或者我应该尝试重新安装Haskell平台?

Thank you. 谢谢。

我得到ghc通过从文件的开头删除模块声明将我的程序链接到可执行文件。

Has it produced an a.exe or a.out.exe or a.out file instead? 它是否生成了a.exe或a.out.exe或a.out文件? If not, then maybe you can just link it yourself? 如果没有,那么也许你可以自己链接它? ld -o hello.exe hello.o or whatever the link command is on your platform. ld -o hello.exe hello.o或您平台上的链接命令。

I would use the --make option, as in ghc --make hello.hs . 我会使用--make选项,如ghc --make hello.hs (You can actually leave out the file extension if you like.) This will automatically figure out what needs to be done, which packages if any need to be linked in, and generally do everything you'd expect. (如果你愿意,你实际上可以省略文件扩展名。)这将自动确定需要做什么,哪些包需要链接,并且通常做你期望的一切。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM