realgcc.exe: error: \build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes-tmp\Main.o: No such file or directory - haskell

I am trying to set up a simple project so I can learn haskell, well, learn it from the ground up to get a better understanding of the theoretical concepts underpinning it. I do however seem to get this error when trying to build it using cabal.
I was trying to build it and was expecting the default main file for cabal to work.
My file system
module Main where
main :: IO ()
main = putStrLn "Hello, Haskell!"
I am using ghc version 8.10.7
I am running the following commands:
cabal init
cabal build
and then I get the error on the build command/
The full error:
Build profile: -w ghc-9.2.5 -O1
In order, the following will be built (use -v for more details):
Graham-Hutton-Haskell-Excersizes-0.1.0.0 (exe:Graham-Hutton-Haskell-Excersizes) (first run)
Preprocessing executable 'Graham-Hutton-Haskell-Excersizes' for Graham-Hutton-Haskell-Excersizes-0.1.0.0..
Building executable 'Graham-Hutton-Haskell-Excersizes' for Graham-Hutton-Haskell-Excersizes-0.1.0.0..
Linking C:\Users\beren\source\repos\Graham Hutton Haskell Excersizes\dist-newstyle\build\x86_64-windows\ghc-9.2.5\Graham-Hutton-Haskell-Excersizes-0.1.0.0\x\Graham-Hutton-Haskell-Excersizes\build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes.exe ...
realgcc.exe: error: C:\Users\beren\source\repos\Graham Hutton Haskell Excersizes\dist-newstyle\build\x86_64-windows\ghc-9.2.5\Graham-Hutton-Haskell-Excersizes-0.1.0.0\x\Graham-Hutton-Haskell-Excersizes\build\Graham-Hutton-Haskell-Excersizes\Graham-Hutton-Haskell-Excersizes-tmp\Main.o: No such file or directory
gcc.exe' failed in phase Linker'. (Exit code: 1)
edit:
https://github.com/bacdekker/haskell-excersizes

Well, after checking/installing/updating gcc it ended up working after I made a new project in a different directory.

Related

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)

haskell fail to import Data.List module

|
4 | import Data.List.Split
| ^^^^^^^^^^^^^^^^^^^^^^
-- While building package myproj-0.1.0.0 using:
Process exited with code: ExitFailure 1
I got this error, how can i import the module to haskell file?
I got this error when compile in vs code or when debugging
Second error in file after compile with stack build, i already added Split in cabal build depends
Cabal file
Building all executables for `myproj' once. After a successful build of all of them, only specified executables will be rebuilt.
myproj> configure (exe)
Warning: myproj.cabal:21:10: Tabs used as indentation at 21:10
Configuring myproj-0.1.0.0...
myproj> build (exe)
Preprocessing executable 'myproj' for myproj-0.1.0.0..
Building executable 'myproj' for myproj-0.1.0.0..
<no location info>: error:
output was redirected with -o, but no output will be generated
because there is no Main module.
First you need to find out in which package the module is included.
https://hoogle.haskell.org/?hoogle=Data.List.Split
So you need the split package. Put in the build-depends of your myproj.cabal file (or package.yaml, if you use hpack or stack)
split >=0.2 && <0.3
(the version bounds are optional, but it's recommended to fix the x.y when in doubt)
Then, at next build, cabal or stack will pull in the required dependencies and thus make the module available.

Stack can't find -lncursesw

When I try compiling my Haskell program with Stack, I get the following error:
Building executable 'fractal' for fractal-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/build/fractal/fractal-tmp/Main.o )
<command line>: can't load .so/.DLL for: /usr/lib/gcc/x86_64-unknown-linux-gnu/8.2.0/../../../../lib/libtinfo.so (-lncursesw: cannot open shared object file: No such file or directory)
-- While building custom Setup.hs for package fractal-0.1.0.0 using:
/home/lorxu/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1 build lib:fractal exe:fractal --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
When I compile with GHC directly, it works fine, and libncursesw.so is present in /usr/lib. I'm on Void Linux. Any ideas where Stack is looking?
This looks like an issue with the bindist Stack has chosen for Void Linux - it normally guesses right, but it can cause issues on some distros. The tinfo6 variant tries to load libtinfo.so, since some distributions provide ncurses6 through that shared object file. You can try configuring the variant manually - you'll probably want standard. Stack will install a new GHC version if you do that, but it will change what shared object it tries to load for ncurses.
EDIT:
This was actually caused by an issue with GHC - if the distro links between the various ncurses files with a linker file, instead of an actual link, GHC won't follow it properly and instead complain that the file doesn't exist. The solution is to replace the linker file with a link to the target.

Text/Regex/TDFA/NewDFA/Engine.hs:13:33: parse error on input ‘#’

I have been trying to run a simple Haskell program using TDFA. The program is as follows:
import Control.Monad
import Data.Array
import qualified Data.Text as T
import Text.Regex
import Text.Regex.TDFA
import Text.Regex.Base
str = "abbbbaab" :: String
regex = "(a+)(b+)" :: String
main = do
if str (=~) :: regex then putStrLn "matched" else putStrLn "no matches"
when I try to run the above program using the command like: ghc test.hs -o test and then I am getting the following error (test.hs is the Haskell program which contains the above code):
Text/Regex/TDFA/NewDFA/Engine.hs:13:33: parse error on input ‘#’
Note that I have the latest version of TDFA installed on my pc. I did it by following ways:
ghc --make -o setup Setup.hs
Also, I did the following:
user#user-VirtualBox:~/regex-tdfa-master$ sudo cabal install regex-tdfa
[sudo] password for user:
Resolving dependencies...
All the requested packages are already installed:
regex-tdfa-1.2.2
Use --reinstall if you want to reinstall anyway.
I even tried it with the Makefile which I got from TDFA's github repository:
user#user-VirtualBox:~/regex-tdfa-master$ make
ghc -o setup --make ./Setup.hs
./setup clean
cleaning...
./setup configure --prefix=/Users/user/local/devel/trl --enable-library-profiling --user
Configuring regex-tdfa-1.2.2...
./setup build
Building regex-tdfa-1.2.2...
Preprocessing` library regex-tdfa-1.2.2...
[ 1 of 23] Compiling Text.Regex.TDFA.NewDFA.Uncons ( Text/Regex/TDFA/NewDFA/Uncons.hs, dist/build/Text/Regex/TDFA/NewDFA/Uncons.o )
...........(Skipped to make the things short here)..............................
[23 of 23] Compiling Text.Regex.TDFA ( Text/Regex/TDFA.hs, dist/build/Text/Regex/TDFA.o )
Text/Regex/TDFA.hs:60:8:
Could not find module ‘Text.Regex.Base’
Perhaps you haven't installed the profiling libraries for package ‘regex-base-0.93.2#regex_47KXx9dLqeO8MNJeizLKhP’?
Use -v to see a list of the files searched for.
Text/Regex/TDFA/ByteString.hs:24:8:
Could not find module ‘Text.Regex.Base.Impl’
Perhaps you haven't installed the profiling libraries for package ‘regex-base-0.93.2#regex_47KXx9dLqeO8MNJeizLKhP’?
Use -v to see a list of the files searched for.
Text/Regex/TDFA/CorePattern.hs:37:8:
Could not find module ‘Control.Monad.RWS’
Perhaps you haven't installed the profiling libraries for package ‘mtl-2.2.1#mtl_Aue4leSeVkpKLsfHIV51E8’?
Use -v to see a list of the files searched for.
Text/Regex/TDFA/ReadRegex.hs:13:8:
`Could not find module ‘Text.ParserCombinators.Parsec’`
Perhaps you haven't installed the profiling libraries for package ‘parsec-3.1.9#parse_EE5NO1mlYLh4J8mgDEshNv’?
Use -v to see a list of the files searched for.
Text/Regex/TDFA/String.hs:23:8:
Could not find module ‘Text.Regex.Base.RegexLike’`
Perhaps you haven't installed the profiling libraries for package ‘regex-base-0.93.2#regex_47KXx9dLqeO8MNJeizLKhP’?
Use -v to see a list of the files searched for.
Text/Regex/TDFA/TDFA.hs:10:8:`
Could not find module ‘Control.Monad.State’
Perhaps you haven't installed the profiling libraries for package ‘mtl-2.2.1#mtl_Aue4leSeVkpKLsfHIV51E8’?
Use -v to see a list of the files searched for.
Makefile:16: recipe for target 'build' failed
make: *** [build] Error 1
user#user-VirtualBox:~/regex-tdfa-master$
However, nothing worked. Hence, any help would be so appreciated...
Text/Regex/TDFA/NewDFA/Engine.hs:13:33: parse error on input ‘#’
On an initial note, this error points to a module of the regex-tdfa package, so you should have gotten it when building the package, rather than when building your test.hs, unless you were trying to build test.hs after putting it within the package source tree. In any case, line 13 of the mentioned file is:
import GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#)
The # names require the MagicHash GHC extension to be enabled. As there is no {-# LANGUAGE MagicHash #-} pragma at the beginning of the file, one should assume the extension is enabled through the .cabal file of the package, and that is indeed the case. That being so, your problem seems to be that you are attempting use the package modules straight from the source tree, without using an appropriate build tool such as Cabal. (Note that if you did successfully run cabal install regex-tdfa there should be no need of dealing with the source tree: ghc --make -o test test.hs should be enough.)
P.S.: There is an error in your test.hs. The last line should be...
if str =~ regex then putStrLn "matched" else putStrLn "no matches"
(I did manage to run it after this correction.)
It looks like you are compiling your program from within Regex-TDFA source code. I am able to reproduce your problem if I do cabal unpack regex-tdfa && cd regex-tdfa-1.2.2 && ghc --make test.hs.
The error happens because when GHC finds Regex-TDFA source files in the current directory, it just picks them and tries to compile, as if they were ordinary source files belonging to your project. However, Regex-TDFA cannot be built with simple ghc --make: in order to build it, you have to run cabal first. Cabal will read regex-tdfa.cabal file that contains the list of the necessary GHC extensions.
In particular, parse error happens because GHC extension MagicHash is missing (that's where the hash # comes from).
The "fix" is to move your test.hs to some other location: then GHC will use system package for Regex-TDFA.

Haskell Yesod problems

someone could help me?! I'm working in a Haskell Yesod site for college on a C9 workspace, I've already installed by command Yesod and update cabal, but when I try "stack build" command, this miserable error message appears:
$ stack build
aulahaskell-0.0.0: build (lib + exe)
Preprocessing library aulahaskell-0.0.0...
[ 7 of 13] 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/web2017/src/Handler/Cliente.hs:10:1: error:
Failed to load interface for ‘Network.HTTP.Types.Status’
It is a member of the hidden package ‘http-types-0.9.1’.
Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package aulahaskell-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:aulahaskell exe:aulahaskell --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Seriously, I tried a bunch of things to fix it, but nothing is working =S
Just read the error message carefully:
Failed to load interface for ‘Network.HTTP.Types.Status’
It is a member of the hidden package ‘http-types-0.9.1’.
Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
The line Perhaps you need to add ‘http-types’ to the build-depends in your .cabal file tells you what to do: You must add http-types to the build-depends: section of the library aulahaskell in your cabal file.
If this does not help, please post your cabal file.
How did you start the yesod project? It's recommended to do:
stack new my-yesod-project yesod-(your database here)
cd my-yesod-project
stack build
Thank you, guys! It was a problem on how I was starting the project, some files weren't installed on my workspace, so I delete the files, reinstall Yesod and cabal, create another new version after following this steps: https://www.yesodweb.com/page/quickstart

Resources