我已经通过预生成的安装程序安装v6.8.2 Haskell中。

当试图编译与GHC此示例文件

module Main where
import Text.ParserCombinators.Parsec
import System.Environment

main :: IO ()
main = do args <- getArgs
          putStrLn ("Hello")

我得到以下错误:

D:\src\Haskell>ghc -o read read.hs
ghc -o read read.hs
read.o(.text+0x1b5):fake: undefined reference to   `__stginit_parseczm2zi1zi0zi0_TextziParserCombinatorsziParsec_'
collect2: ld returned 1 exit status

我已经通过小集团安装秒差距。

有没有人有任何想法的,什么是错的?

有帮助吗?

解决方案

尝试ghc --make -o read read.hs。 GHC将接头依赖性照顾。

其他提示

我会拿出一个别的办法,使这项工作。

ghc -package parsec -o read read.hs

从GHC文档

-package P

This option causes the installed package P to be exposed. The package P can be 
specified in full with its version number (e.g. network-1.0) or the version number 
can be omitted if there is only one version of the package installed. If there are 
multiple versions of P installed, then all other versions will become hidden.

The -package P option also causes package P to be linked into the resulting 
executable or shared object. Whether a packages' library is linked statically or 
dynamically is controlled by the flag pair -static/-dynamic.

http://www.haskell.org/ GHC /文档/最新/ HTML / users_guide / packages.html中

根据的秒差距文档(第1.2节。 1 GHC编译),你应该这样做:

  

当您将文件链接在一起,   你需要告诉GHC哪里能找到   库(-L)和与所述连结   秒差距库太(-l):点击     的 ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec

此文档上所述Haskell编译可能有帮助。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top