2009-11-04 19 views
6

Ich habe Haskell über den vorinstallierten Installer v6.8.2 installiert.Haskell Parsec kompilieren Fehler

Wenn mit GHC

diese Beispieldatei zu kompilieren versuchen
module Main where 
import Text.ParserCombinators.Parsec 
import System.Environment 

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

bekomme ich folgende Fehlermeldung:

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 

Ich habe Parsec über Kabale installiert.

Hat jemand eine Idee, was ist falsch?

Antwort

9

Versuchen Sie ghc --make -o read read.hs. GHC wird sich um Linker-Abhängigkeiten kümmern.

+0

Das scheint zu funktionieren, vielen Dank – chollida

1

Nach the Parsec docs (Abschnitt 1.2.1 Kompilieren mit GHC), sollten Sie dies tun:

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 auf dem Haskell Compiler helfen können.

+0

Nicht ganz das, was ich suchte, aber trotzdem danke zum Ausprobieren;) – chollida

+0

Gern geschehen. Es war eine Vermutung. –

2

Ich werde eine andere Art und Weise löscht diese Arbeit zu machen

ghc -package parsec -o read read.hs 

die GHC Dokumentation

-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. 

siehe http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html