2009-11-04 12 views
6

ビルド済みのインストーラv6.8.2からHaskellをインストールしました。Haskell Parsecコンパイルエラー

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 

私は徒党を経由してParsecのがインストールされています。

何が間違っていると思いますか?

答えて

9

お試しghc --make -o read read.hs GHCはリンカーの依存関係を処理します。

+0

これは動作するようですが、多くの感謝 – chollida

1

the Parsec docs(GHCでコンパイルセクション1.2.1)によると、あなたはこれを行う必要があります:Haskellのコンパイラに

When your linking the files together, you need to tell GHC where it can find libraries (-L) and to link with the Parsec library too (-l):
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec

This documentationを助けるかもしれません。

+0

を見ます試してみる;) – chollida

+0

あなたは大歓迎です。それは推測だった。 –

2

私はGHCのドキュメントから

ghc -package parsec -o read read.hs 

この作品を作るための一つの他の方法を出します

-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/docs/latest/html/users_guide/packages.html