在 Cygwin 中编译 Haskell 代码,以及 Windows 上 Haskell 平台中的一些其他错误
我正在尝试使用 Haskell Platform 2011.2.0.1 在 Haskell 中编译一个简单的 hello world 程序。如果我在 WinGHCi 中加载代码并使用 GUI 进行编译,则会创建 .exe。然后我可以从 Cygwin 运行 .exe。
但是,如果我尝试在 Cygwin 中编译代码(使用 ghc --make ),链接器会失败。但同样,如果我从 Windows cmd
提示符进行编译,则编译+链接器可以正常工作。
我是否需要导入任何其他环境变量到 Cygwin 中,以使编译+链接器在其中工作?我已将以下目录放入 Cygwin PATH 中:2011.2.0.1/lib/extralibs/bin
、2011.2.0.1/bin
(这是唯一两个有效的 Haskell 相关条目我可以在 Windows 环境变量中看到)。
我还注意到 Windows 环境变量中有几个无效项目(这看起来像是 Haskell 安装中的错误):
- (system var)
C/ProgramFiles/Haskell/bin
- 该目录不存在,因为我已经把Haskell安装在D盘了。 - (user var)
userxxx/ApplicationData/cabal/bin
- 该目录不存在。
我尝试在 HaskellPlatform 中提交错误报告,但我没有这样做的权限。
I am trying to compile a simple hello world program in Haskell, with Haskell Platform 2011.2.0.1. If I load the code in WinGHCi, and use the GUI to compile, the .exe is created. Then I can run the .exe from Cygwin.
But if I try to compile the code in Cygwin (using ghc --make
), linker fails. But again, if I compile from the Windows cmd
prompt, then the compile+linker works fine.
Are there any other environment variables I need to import into Cygwin, to make the compile+linker work in it? I have put the following dirs in my Cygwin PATH: 2011.2.0.1/lib/extralibs/bin
, 2011.2.0.1/bin
(these are the only two valid Haskell related entries that I could see in the Windows environment variables).
I also noticed a couple of invalid items in the Windows environment variables (this looks like a bug in the Haskell installation):
- (system var)
C/ProgramFiles/Haskell/bin
- this dir does not exist because I have installed Haskell in D disk. - (user var)
userxxx/ApplicationData/cabal/bin
- this dir does not exist.
I tried to file a bug report in HaskellPlatform, but I dont have permission to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于无法访问您的开发环境或您遇到的错误列表,我只能假设该问题与您设置
PATH
的方式有关。Windows 上的 GHC 捆绑了自己的
gcc
编译器(用于 C 代码)和ld
链接器。如果您安装了 Cygwin,那么您可能还安装了 MinGW 工具链,它附带了自己的gcc
和ld
版本。然后,您可能已经在 Haskell Platform 二进制目录的路径之前创建了PATH
变量列表/usr/bin
,这使得ghc
找到MinGW 链接器和 C 编译器,然后再找到与 GHC 捆绑在一起的版本。您需要确保 HP 目录列在 Cygwin 目录之前。它不应该是这样的:
相反,它应该是这样的:
这只是对问题可能是什么的猜测,您应该提供更多详细信息以便更好地诊断。
Without access to your development environment or a listing of the errors that you're getting, I can only assume that the issue is related to the way that you've set up your
PATH
.GHC on Windows comes bundled with its own
gcc
compiler (for C code) andld
linker. If you've installed Cygwin, you've probably also installed the MinGW toolchain, which comes with its own version ofgcc
andld
. Then, you've probably made yourPATH
variable list/usr/bin
before the path to the Haskell Platform binary directories, which makesghc
find the MinGW linker and C compiler before it finds the versions that were bundled with GHC.You need to make sure that the HP directories are listed before the Cygwin directories. It should not be like this:
Instead, it should be like this:
This is only a guess at what the issue might be, and you should provide more details for a better diagnosis.