Home > other >  Haskeline throws linking error in stack build
Haskeline throws linking error in stack build

Time:01-02

I'm trying to build haskell project via stack build command, but it throws 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

Also it outputs following error in log file:

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)


My code haven't any errors in .hs files. Also I can invoke any function (even main) via stack ghciand it works fine. After some researches I found that if I'll remove haskeline from dependencies in %project name%.cabal file, stack build will execute witout any problems.

I use haskeline only in app/main.hs and my code is from this site. Here it is

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

Here is part of .cabal file where I'm adding 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

Version of haskeline doesn't matter. I tried to set previous versions and error occured with each of them. I tried to google problem, but it seems that nobody faced it before or it's too trivial to ask about. I'm using linux mint, maybe it impacts somehow. I fully reinstalled stack but problem is still with me. Deleting temporary files like .stack-work within project also didn't help

CodePudding user response:

The problem were due to the missing libtinfo-dev. Once I had library installed the problem disappeared. Thanks to the answer in comments

  • Related