문제

사전 제작자 v6.8.2를 통해 Haskell을 설치했습니다.

이 샘플 파일을 GHC로 컴파일하려고 할 때

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

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

다음 오류가 발생합니다.

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

Cabal을 통해 Parsec을 설치했습니다.

무엇이 잘못되었는지에 대한 아이디어가 있습니까?

도움이 되었습니까?

해결책

노력하다 ghc --make -o read read.hs. GHC는 링커 종속성을 처리합니다.

다른 팁

이 작업을 수행 할 수있는 다른 방법 중 하나를 내놓을 게요

ghc -package parsec -o read read.hs

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

에 따르면 Parsec 문서 (섹션 1.2.1 GHC 컴파일) :이 작업을 수행해야합니다.

파일을 함께 연결하면 GHC에 라이브러리 (-L)를 찾을 수있는 위치 (-L)와 PARSEC 라이브러리 (-L)와 연결해야합니다.
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec

이 문서 Haskell 컴파일러에서 도움이 될 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top