An error in "stack build" of haskell which doesn't make sense - haskell

So far, for weeks, everything has been ok. But all of a sudden "stack build" has begun returning this (obfuscated a bit):
$ stack build
MyLib-0.1.0.1: build
Preprocessing library MyLib-0.1.0.1...
[53 of 55] Compiling Web.MyLib.SomeFile.MyFile ( src/Web/MyLib/SomeFile/MyFile.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Web/MyLib/SomeFile/MyFile.o )
In-place registering MyLib-0.1.0.1...
Preprocessing executable 'MyLib-exe' for MyLib-0.1.0.1...
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/MyLib-exe/MyLib-exe ...
.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/MyLib-exe/MyLib-exe-tmp/Main.o:(.text+0xf6): undefined reference to `fdsfdzuC6HIw1NjUcr0zzrqlCnCP5y_WebziMyLibziSomeFileziMyFile_MyFileGetSingle1_info'
.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/MyLib-exe/MyLib-exe-tmp/Main.o: In function `S6VL_srt':
(.data+0xe8): undefined reference to `fdsfdzuC6HIw1NjUcr0zzrqlCnCP5y_WebziMyLibziSomeFileziMyFile_MyFileGetSingle1_closure'
collect2: error: ld returned 1 exit status
-- While building package MyLib-0.1.0.1 using:
/home/me123/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:MyLib exe:MyLib-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
I've done "stack update, upgrade" but it's not helped.

Related

Haskeline throws linking error in stack build

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
The problem were due to the missing libtinfo-dev. Once I had library installed the problem disappeared. Thanks to the answer in comments

Haskell linker unable to open output file

I am new to Haskell and I am using cabal for a small project. The project is managed on github and it works fine if I run cabal run on the current code. There are also no errors if I enter ghci *.hs However, if I make any changes to the code at all, the following is printed to the terminal. What might be the issue here?
C:\Users\65963\scripting-hs> cabal run
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
- scripting-hs-0.1.0.0 (exe:scripting-hs) (configuration changed)
Configuring executable 'scripting-hs' for scripting-hs-0.1.0.0..
Preprocessing executable 'scripting-hs' for scripting-hs-0.1.0.0..
Building executable 'scripting-hs' for scripting-hs-0.1.0.0..
Linking C:\Users\65963\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe ...
C://ProgramData//chocolatey//lib//ghc//tools//ghc-8.10.3//mingw//bin/ld.exe: cannot open output file C:\Users\65963\CS Projects\St Andrews CS\CS2006\CS2006-Haskell2\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

Problems using a Postgres database in a Haskell Yesod application

I'm trying to use a Heroku Postgres database on my Yesod application in a c9 workspace, but the following error message appears when the stack build command is running:
$ stack build
projeto-0.0.0: build (lib + exe)
Preprocessing library projeto-0.0.0...
[ 9 of 15] Compiling Handler.Cliente ( src/Handler/Cliente.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Handler/Cliente.o )
/home/ubuntu/workspace/projeto/src/Handler/Cliente.hs:11:1: error:
Failed to load interface for ‘Database.Persist.Postgresql’
Use -v to see a list of the files searched for.
-- While building package projeto-0.0.0 using:
/home/ubuntu/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 build lib:projeto exe:projeto --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
What I should do?

Trouble trying to use CmdArgs in Haskell (Failed to load interface for ‘CmdArgs’)

I am currently trying to use CmdArgs and I am running into some trouble.
The code is here on github and the error I am getting is this:
$ stack build
gc2-0.1.0.0: configure (lib + exe) Configuring
gc2-0.1.0.0... gc2-0.1.0.0: build (lib + exe) Preprocessing library
gc2-0.1.0.0... Preprocessing executable 'gc2-exe' for gc2-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs,
.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/gc2-exe/gc2-exe-tmp/Main.o )
/home/kuwze/src/haskell/gc2/app/Main.hs:6:1: error:
Failed to load interface for ‘CmdArgs’
Use -v to see a list of the files searched for.
-- While building package gc2-0.1.0.0 using:
/home/kuwze/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build lib:gc2 exe:gc2-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Any help would be greatly appreciated.
It turns out like usual I am an idiot.
The correct thing to do is to check the full path of a library; for my example the page for CmdArgs specifies that the library path for the module is System.Console.CmdArgs.

stack build results in ExitFailure 1 with Yesod

I'm trying to get started with Yesod development on Windows, but I cannot seem to build the generated bare app. I followed all the quick start guide steps. Specifically, it fails on step 4, when I execute the
stack build
command. The following output is generated.
C:\Users\Vitor Coimbra\testeyesod>stack build
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
Teste-0.0.0: build
Preprocessing library Teste-0.0.0...
In-place registering Teste-0.0.0...
Preprocessing executable 'Teste' for Teste-0.0.0...
Linking .stack-work\dist\x86_64-windows\Cabal-1.22.4.0\build\Teste\Teste.exe ...
ghc.exe: could not execute: C:\Program Files\Haskell Platform\7.10.2-a\lib/../mingw/bin/gcc.exe
ghc: warning: _tzset from msvcrt is linked instead of __imp__tzset
-- While building package Teste-0.0.0 using:
C:\\Program Files\\Haskell Platform\\7.10.2-a\\bin\\runhaskell.exe -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=C:\Users\Vitor Coimbra\AppData\Roaming\stack\snapshots\x86_64-windows\lts-3.1\7.10.2\pkgdb\ C:\Users\VITORC~1\AppData\Local\Temp\stack5620\Setup.hs --builddir=.stack-work\dist\x86_64-windows\Cabal-1.22.4.0\ build exe:Teste --ghc-options -hpcdir .stack-work\dist\x86_64-windows\Cabal-1.22.4.0\hpc\.hpc\ -ddump-hi -ddump-to-file
Process exited with code: ExitFailure 1
The project was created with the name Teste and with SQLite as the persistence layer.

Resources