2009-11-04 9 views
6

He instalado Haskell a través del instalador preconstruido v6.8.2.Haskell Error de compilación de Parsec

Al intentar compilar este archivo de ejemplo con GHC

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

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

me sale el siguiente error:

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 

He instalado Parsec a través de Cabal.

¿Alguien tiene alguna idea de lo que está mal?

Respuesta

9

Pruebe ghc --make -o read read.hs. GHC se ocupará de las dependencias del vinculador.

+0

Esto parece funcionar, muchas gracias – chollida

1

Según the Parsec docs (sección 1.2.1 Compilar con GHC), usted debe hacer esto:

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 en el compilador de Haskell puede ayudar.

+0

No es exactamente lo que estaba buscando, pero gracias de todos modos para intentar;) – chollida

+0

De nada. Fue una suposición. –

2

voy a poner a cabo una otra manera de hacer este trabajo

ghc -package parsec -o read read.hs 

De la documentación 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. 

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

Cuestiones relacionadas