Haskell Parsec errore di compilazione
Domanda
Ho installato Haskell tramite il pre costruita installazione v6.8.2.
Quando si cerca di compilare questo file di esempio con GHC
module Main where
import Text.ParserCombinators.Parsec
import System.Environment
main :: IO ()
main = do args <- getArgs
putStrLn ("Hello")
ottengo il seguente errore:
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
Ho installato Parsec via cabala.
Qualcuno ha qualche idea di come a ciò che è sbagliato?
Soluzione
Prova ghc --make -o read read.hs
. GHC si prenderà cura delle dipendenze linker.
Altri suggerimenti
Metterò fuori un altro modo per fare questo lavoro
ghc -package parsec -o read read.hs
Dalla documentazione 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 / docs / ultima / html / users_guide / packages.html
la documentazione Parsec (punto 1.2. 1 la compilazione con GHC), si dovrebbe fare questo:
Quando il vostro collega i file insieme, è necessario indicare GHC dove può trovare librerie (-L) e al collegamento con la biblioteca Parsec troppo (-l):
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec
Questa documentazione su il compilatore Haskell può aiutare.