Haskell Parsec Compile Error
سؤال
لقد قمت بتثبيت Haskell عبر المثبت مسبقا V6.8.2.
عند محاولة ترجمة ملف العينة هذا مع 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
لقد قمت بتثبيت Parsec عبر Cabal.
هل لدى أي شخص أي فكرة حول ما هو الخطأ؟
المحلول
محاولة 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) والربط مع مكتبة PARSEC أيضا (-L):
ghc -o myprogram myfile1.o myfile2.o -Lc:\parsec -lparsec
هذه الوثائق في مترجم Haskell قد يساعد.
لا تنتمي إلى StackOverflow