Haskeline 在堆栈构建中抛出链接错误

Haskeline throws linking error in stack build

我正在尝试通过 stack build 命令构建 haskell 项目,但它抛出异常:

--  While building package %some secret project name%-0.1.0.0 (scroll up to its section to see the error) using:
      /home/%some secret username%/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build lib:%some secret project name% exe:%exe name% --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

还在日志文件中输出以下错误:

Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/%secret name%/%secret name% ...
/usr/bin/ld.gold: error: cannot find -ltinfo
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/haskeline-0.8.2/libHShaskeline-0.8.2.a(Terminfo.o)(.text..LsmG9_info+0x76): error: undefined reference to 'set_curterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/haskeline-0.8.2/libHShaskeline-0.8.2.a(Terminfo.o)(.text..LsmG9_info+0xcc): error: undefined reference to 'set_curterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/haskeline-0.8.2/libHShaskeline-0.8.2.a(Terminfo.o)(.text..LsmG9_info+0x147): error: undefined reference to 'set_curterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/haskeline-0.8.2/libHShaskeline-0.8.2.a(Terminfo.o)(.text..LsmG9_info+0x1bb): error: undefined reference to 'set_curterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Lr5WM_info+0xb2): error: undefined reference to 'tigetnum'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Lr5WN_info+0xb2): error: undefined reference to 'tigetflag'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Lr5WO_info+0xb2): error: undefined reference to 'tigetstr'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Ls64w_info+0x354): error: undefined reference to 'tparm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Ls66r_info+0x129): error: undefined reference to 'setupterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Ls66r_info+0x22a): error: undefined reference to 'del_curterm'
/home/messieurme/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/lib/ghc-8.10.7/terminfo-0.4.1.4/libHSterminfo-0.4.1.4.a(Base.o)(.text..Ls68h_info+0x141): error: undefined reference to 'tputs'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)


我的代码在 .hs 文件中没有任何错误。我也可以通过 stack ghci 调用任何函数(甚至是 main)并且它工作正常。 经过一些研究,我发现如果我从 %project name%.cabal 文件中的依赖项中删除 haskelinestack build 将执行而不会出现任何问题。

我只在 app/main.hs 中使用 haskeline,我的代码来自 this site。在这里

import System.Console.Haskeline

main :: IO ()
main = runInputT defaultSettings loop
   where
       loop :: InputT IO ()
       loop = do
           minput <- getInputLine "% "
           case minput of
               Nothing -> return ()
               Just "quit" -> return ()
               Just input -> do outputStrLn $ "Input was: " ++ input
                                loop

这是我添加 haskeline 的 .cabal 文件的一部分:

executable hi
  hs-source-dirs:      app
  main-is:             %Some secret main name%.hs
  ghc-options:         -Wall -Werror -threaded -rtsopts -with-rtsopts=-N
  build-depends:       base >= 4.9 && < 5
                     , %extra deps%
                     , haskeline
  default-language:    Haskell2010

haskeline 的版本无关紧要。我试图设置以前的版本,但每个版本都发生了错误。 我尝试 google 问题,但似乎以前没有人遇到过这个问题,或者问这个问题太微不足道了。 我正在使用 linux mint,也许它会以某种方式产生影响。 我完全重新安装了堆栈,但问题仍然存在。删除项目中的 .stack-work 等临时文件也无济于事

问题是由于缺少 libtinfo-dev。一旦我安装了库,问题就消失了。感谢评论中的回答