Haskell - GHC 中的编译问题

发布于 2025-01-06 00:16:34 字数 380 浏览 5 评论 0原文

我对 Haskell 非常陌生,最近我用 GHC 安装了该平台。我决定通过编译一个简单的 Hello world 程序来测试它: main = putStrLn "Hello, world"

现在,当我进入命令行 (Windows 7) 时,找到正确的目录,然后键入在 ghc hello.hs 中,它返回以下消息:“[1 of 1] Compiling Main (hello.hs, hello.o)”。我知道一旦完成编译,它应该遵循“Linking hello.exe ...”,但那永远不会出现,并且不会生成 .exe。

基本上,是否有任何明显的原因导致这种情况发生?代码是否有问题,是否有什么我不知道的事情,或者我应该尝试重新安装 Haskell 平台?

谢谢。

I'm very new to Haskell, and I've recently installed the platform with GHC. I decided to test it out by compiling a simple Hello world program: 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 )". I understand that once it's done compiling, it should follow with "Linking hello.exe ...", but that never comes, and no .exe is produced.

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?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌上芳菲 2025-01-13 00:16:34

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

I got ghc to link my program into an executable by removing module declaration from the start of the file.

合久必婚 2025-01-13 00:16:34

它是否生成了 a.exe 或 a.out.exe 或 a.out 文件?如果没有,那么也许你可以自己链接它? ld -o hello.exe hello.o 或您平台上的任何链接命令。

Has it produced an a.exe or a.out.exe or a.out file instead? 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.

青衫负雪 2025-01-13 00:16:34

我将使用 --make 选项,如 ghc --make hello.hs 中所示。 (如果您愿意,您实际上可以省略文件扩展名。)这将自动找出需要做什么,如果需要链接哪些包,并且通常会执行您期望的所有操作。

I would use the --make option, as in 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文