首页 > 解决方案 > 运行 Haskell 代码时,“gcc.exe”在“汇编程序”阶段失败

问题描述

我有以下 Haskell 代码,它简单地显示两个数字的和、差、积和商,以及从 1 到 10 的数字范围和字母。

main = do

    let a = 5
    let b = 10
    
    putStrLn "The addition of the two numbers is: "
    print(a + b);
    
    putStrLn "The subtraction of the two numbers is: "
    print(a - b);
    
    putStrLn "The multiplication of the two numbers is: "
    print(a * b);
    
    putStrLn "The division of the two numbers is: "
    print(a * b);
    
    print [1..10]
    print ['a'..'z']

我在在线编译器上运行它,它似乎可以工作,但是当我将它粘贴到记事本上并通过终端运行它时,它显示了错误:

Fatal error: can't create basicOperators.o: No such file or directory
`gcc.exe' failed in phase `Assembler'. (Exit code: 1)

这很有趣,因为我的计算机上安装了 GHC,并且 Haskell 编译器几天前工作得很好,但现在它停止工作了。我仍然是 Haskell 的初学者,我需要了解如何避免出现此错误。如果有人有想法,我将不胜感激。

标签: haskellghc

解决方案


作为@n。'代词'我评论说,GHC 似乎在写入此文件夹时遇到问题。尝试使用不同的文件夹,例如创建C:\Temp、复制代码并从那里编译。


推荐阅读