我试图通过stack build
命令构建haskell项目,但它抛出了excepton:
-- 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函数(,而且它运行良好。经过一些研究,我发现如果我将haskeline
从%project name%.cabal
文件中的依赖项中删除,stack build
将在没有任何问题的情况下执行。
我只在app/main.hs中使用haskeline
,我的代码来自这个网站。这是
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
这是.cab文件的一部分,我在其中添加了haskeline:
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的版本并不重要。我试图设置以前的版本,但每个版本都出现了错误。我试着用谷歌搜索这个问题,但似乎以前并没有人面对过,或者这太琐碎了,问不起。我使用的是linux mint,也许它会产生某种影响。我完全重新安装了堆栈,但问题仍然存在。删除项目中的临时文件,如.stack工作也没有帮助
问题是由于缺少libtinfo-dev
。一旦我安装了图书馆,问题就消失了。感谢评论中的回答