问题指定源目录为GHC [英] Problem Specifying Source Directory to GHC

查看:98
本文介绍了问题指定源目录为GHC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个令人尴尬的简单问题,但其解决方案仍然没有解决。正如标题所示,我只是想指定GHC所有源文件的位置。这应该很简单; GHC用户指南


-i



标志附加一个以冒号分隔的
目录列表到搜索路径。


所以,我尝试了下面的调用:

  ghc -isrc / -v -outputdir build / --make -Wall Main.hs 
ghc -isrc /: -v -outputdir build / --make -Wall Main.hs
ghc -i:src /:-v -outputdir build / --make -Wall Main.hs
ghc -isrc / -v -outputdir build / --make -Wall Main.hs
ghc -isrc /:-v -outputdir build / --make -Wall Main.hs
ghc -i:src /:-v -outputdir build / --make -Wall Main.hs

在每次调用GHC给出错误:< no location info> ;:无法找到文件:Main.hs



正如你可能已经猜到的,Main.hs位于来自工作目录的子目录称为src。以防万一,我使用的是Windows XP,而且我正在使用GHC 6.12.2。我假设有一个小问题,我只是想念。

<> 源文件,而不是您在命令行中指定的文件。所以你的 Main.hs 也需要一个src /前缀。例如

  $ ghc -isrc src / Main.hs --make 
[1 of 1] Compiling Main(src /Main.hs,src / Main.o)
链接src / Main ...

或者,您可以使用cabal,并为 cabal init 生成所有构建元数据。


This is an embarrassingly simple problem, but its solution yet eludes me. As the title indicates, I simply want to specify to GHC the location of all my source files. This should be simple; the GHC user guide:

-idirs

This flag appends a colon-separated list of dirs to the search path.

So, I tried the following invocations:

ghc -isrc/ -v -outputdir build/ --make -Wall Main.hs
ghc -isrc/: -v -outputdir build/ --make -Wall Main.hs
ghc -i:src/: -v -outputdir build/ --make -Wall Main.hs
ghc -i"src/" -v -outputdir build/ --make -Wall Main.hs
ghc -i"src/": -v -outputdir build/ --make -Wall Main.hs
ghc -i:"src/": -v -outputdir build/ --make -Wall Main.hs

On every invocation GHC gave the error: "<no location info>: can't find file: Main.hs"

As you probably could have guessed, Main.hs is located in a subdirectory from the working directory called "src". Just in case it matters, I'm on Windows XP, and I'm using GHC 6.12.2. I'm assuming there is some small problem that I'm just missing.

解决方案

-i specifies where GHC will search for other source files, other than the ones you specify on the command line. So your Main.hs there will also need a src/ prefix. E.g.

$ ghc -isrc src/Main.hs --make 
[1 of 1] Compiling Main             ( src/Main.hs, src/Main.o )
Linking src/Main ...

Alternatively, you could use cabal, and have cabal init generate all the build metadata for you.

这篇关于问题指定源目录为GHC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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