无法使用GHC编译haskell源,链接错误

时间:2017-08-26 15:22:10

标签: haskell compilation linker ghc archlinux

我是Haskell的新手。用GHC,我试着编译:

trace.hs,一个简单的光线跟踪器(内容可能并不重要):

import System.IO
import System.Process
import Linear.V3
import Linear.Metric
import Linear.Vector
import Control.Applicative
import Control.Monad

type Scalar = Double
type Vector = V3 Scalar
type Distance = Scalar
type Position = Vector
type Direction = Vector
type Arrow = Vector
type Color = Vector
data Ray = Ray Position Direction


trace :: Ray -> Color
trace (Ray origin direction) = direction

colorToInt x = round $ 255 * sqrt x

main = do
  let image = "image.ppm"
      (nx, ny) = (40, 40)
      eyepos = V3 0 0 0
      genRay dir = Ray eyepos $ normalize dir
      rayGen sx sy = genRay $ V3 sx sy 1
      rayOf x y = let fi = fromIntegral in
                      rayGen (fi x / fi nx + 0.5)
                             (fi y / fi ny + 0.5)
      rays = rayOf <$> [0..nx-1] <*> [0..ny-1]
      result = map (fmap colorToInt) . map trace $ rays

  handle <- openFile image WriteMode
  let put = hPutStrLn handle

  put "P3"
  put $ show nx ++ ' ' : show ny
  put "255"

  forM_ result $ \(V3 r g b) -> do
    put $ show r ++ ' ' : show g ++ ' ' : show b

  hClose handle
  system $ "display " ++ image
  return ()

但发生了错误

bate@archbin:~/hsrt/vuee$ ghc --make trace.hs
Linking trace ...
/usr/local/bin/ld: cannot find -lHSlens-4.15.4-L23zn92GAPI1hUmidWzY63
/usr/local/bin/ld: cannot find -lHSvector-0.12.0.1-692PQMDMB6pIQ1uGwefDcQ
/usr/local/bin/ld: cannot find -lHSth-abstraction-0.2.5.0-IQJC3onXzKuCarhyL6pEOQ
/usr/local/bin/ld: cannot find -lHSreflection-2.1.2-1Oix9U9tVVU4sCEhxeh8Kr
/usr/local/bin/ld: cannot find -lHSparallel-3.2.1.1-KQJHWCcq2Ka569Stb10nhx

...

/usr/local/bin/ld: cannot find -lHSStateVar-1.1.0.4-8WOljMLP9CI2EkNoKyIopY
/usr/local/bin/ld: cannot find -lHSstm-2.4.4.1-iSYwp3RMY11sHCifJ3gtR
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
bate@archbin:~/hsrt/vuee$ 
bate@archbin:~/hsrt/vuee$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
bate@archbin:~/hsrt/vuee$ 
bate@archbin:~/hsrt/vuee$ ls /usr/lib/libHS*
/usr/lib/libHSadjunctions-4.3-IiXaMJ9VhRwGggTqHGtSLU-ghc8.0.2.so
/usr/lib/libHSaeson-1.1.2.0-8R262j8BseM7FTnCfGfbwu-ghc8.0.2.so
/usr/lib/libHSaeson-compat-0.3.7.1-BegDnMRPSO7KSvclD5A4Lc-ghc8.0.2.so
/usr/lib/libHSansi-wl-pprint-0.6.8-442hsaqSoAVL7JUQ0ogC39-ghc8.0.2.so

...

我在Arch Linux,i686上安装了ghc,ghc-static软件包。

自从我重新安装GHC使用后发生错误 sudo pacman -S ghc ghc-static

该错误似乎是由Linear。*

引起的

我已经尝试删除/ usr / local / bin $ PATH,但没什么好。

在/ usr / lib中,我发现了libHS ghc-8.0.2.so。 似乎ghc并没有告诉ld -lHS ghc-8.0.2,为什么?

我该如何解决这个问题?

0 个答案:

没有答案