在Cygwin中编译Haskell代码,以及在Windows上的Haskell Platform中的一些其他错误 [英] Compiling Haskell code in Cygwin, and some other bugs in Haskell Platform on Windows

查看:231
本文介绍了在Cygwin中编译Haskell代码,以及在Windows上的Haskell Platform中的一些其他错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Haskell Platform 2011.2.0.1在Haskell中编译一个简单的hello世界程序。如果我在WinGHCi中加载代码,并使用GUI进行编译,则会创建.exe。然后我可以从Cygwin运行.exe。



但是,如果我尝试编译Cygwin中的代码(使用 ghc --make ),链接器失败。但再一次,如果我从Windows cmd 提示进行编译,那么compile +链接程序可以正常工作。



我需要导入到Cygwin中的任何其他环境变量,以使编译+链接器在其中工作?我在我的Cygwin路径中添加了以下目录: 2011.2.0.1/lib/extralibs/bin 2011.2.0.1/bin

我还注意到Windows环境中的一些无效项变量(这看起来像是Haskell安装中的一个错误):


  1. (system var) C / ProgramFiles / Haskell / bin - 这个目录不存在,因为我在D盘中安装了Haskell。
  2. (user var) userxxx / ApplicationData / cabal / bin - 这个目录不存在。

我试图在HaskellPlatform中提交错误报告,但我没有权限去做这件事。

解决方案

如果没有访问开发环境或者错误列表,我只能假定问题与您设置 PATH 的方式有关。



Windows上的GHC捆绑了它自己的 gcc 编译器(用于C代码)和 ld 链接器。如果你已经安装了Cygwin,你可能还安装了MinGW工具链,它附带了它自己的版本 gcc ld 。然后,你可能在Haskell Platform二进制目录的路径之前创建了 PATH 变量列表 / usr / bin ,它使 ghc 在找到与GHC捆绑的版本之前找到MinGW链接器和C编译器。



您需要确保HP目录在Cygwin目录之前列出。它不应该是这样的:

  $ echo $ PATH 
/ bin:/ usr / bin:... /2011.2.0.1/bin

相反,它应该是这样的:

  $ echo $ PATH 
... / 2011.2.0.1/bin:/bin:/usr/bin

这只是对问题的猜测,您应该提供更多详细信息以便更好地诊断。


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):

  1. (system var) C/ProgramFiles/Haskell/bin - this dir does not exist because I have installed Haskell in D disk.
  2. (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.

解决方案

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) and ld linker. If you've installed Cygwin, you've probably also installed the MinGW toolchain, which comes with its own version of gcc and ld. Then, you've probably made your PATH variable list /usr/bin before the path to the Haskell Platform binary directories, which makes ghc 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:

$ echo $PATH
/bin:/usr/bin:.../2011.2.0.1/bin

Instead, it should be like this:

$ echo $PATH
.../2011.2.0.1/bin:/bin:/usr/bin

This is only a guess at what the issue might be, and you should provide more details for a better diagnosis.

这篇关于在Cygwin中编译Haskell代码,以及在Windows上的Haskell Platform中的一些其他错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆