Pergunta

Eu instalei Haskell via o pré construído instalador v6.8.2.

Ao tentar compilar esse arquivo de exemplo com GHC

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

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

Eu recebo o seguinte erro:

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

Eu instalei Parsec via cabala.

Alguém tem alguma idéia de como o que está errado?

Foi útil?

Solução

ghc --make -o read read.hs tentativa. GHC vai cuidar de dependências vinculador.

Outras dicas

Eu vou colocar para fora uma outra maneira de fazer este trabalho

ghc -package parsec -o read read.hs

A partir da documentação 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 / latest / html / users_guide / packages.html

De acordo com docs Parsec (secção 1.2. 1 Compilando com GHC), você deve fazer isso:

Quando seu ligando os arquivos juntos, você precisa dizer GHC onde ele pode encontrar bibliotecas (-l) e ligação com o biblioteca Parsec também (-l):
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec

Esta documentação em o compilador Haskell pode ajudar.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top