Haskell parsec erreur de compilation
Question
J'ai installé Haskell via le programme d'installation pré construit v6.8.2.
Lorsque vous essayez de compiler ce fichier exemple avec GHC
module Main where
import Text.ParserCombinators.Parsec
import System.Environment
main :: IO ()
main = do args <- getArgs
putStrLn ("Hello")
Je reçois l'erreur suivante:
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
J'ai installé parsec via cabale.
Quelqu'un at-il de idée de ce qui ne va pas?
La solution
Essayez ghc --make -o read read.hs
. GHC prendra en charge les dépendances de liaison.
Autres conseils
Je vais mettre sur une autre façon de faire ce travail
ghc -package parsec -o read read.hs
De la documentation 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.
voir http://www.haskell.org/ GHC / docs / latest / html / users_guide / packages.html
Selon parsec docs (section 1.2. 1 Compiler avec GHC), vous devriez faire ceci:
Lorsque votre lien vers le fichier ensemble, vous devez indiquer GHC où il peut trouver bibliothèques (-L) et faire le lien avec le bibliothèque parsec aussi (-l):
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec
Cette documentation sur le compilateur Haskell peut aider.