I'm new to Haskell but I want to try and write some OpenGL experiments in it.
I've successfully installed OpenGL, GLUT and a few other packages but when I attempt to install GLUtil I get the following error:
Building GLUtil-0.9.0.1...
Failed to install GLUtil-0.9.0.1
Build log ( C:\Users\David\AppData\Roaming\cabal\logs\GLUtil-0.9.0.1.log ):
Building GLUtil-0.9.0.1...
Preprocessing library GLUtil-0.9.0.1...
hpp: Couldn't open input file: -includeC:\Users\David\AppData\Local\Temp\ghc3236_0\ghc_2.h
CallStack (from HasCallStack):
error, called at src\Hpp\CmdLine.hs:89:0: error:
22 in hpp-0.3.0.0-61vdEFyxUJDaeEBxsHCsL:Hpp.CmdLine
`hpp' failed in phase `C pre-processor'. (Exit code: 1)
cabal: Leaving directory 'C:\Users\David\AppData\Local\Temp\cabal-tmp-6356\GLUtil-0.9.0.1'
cabal: Error: some packages failed to install:
GLUtil-0.9.0.1 failed during the building phase. The exception was:
ExitFailure 1
I tried using older versions of GLUtil and its dependencies but it always ended the same way and I eventually just cleared and reinstalled the Haskell Platform (I didn't know about sandboxing).
One thing that stands out is that -includeC:\Users\Dav... looks to me like a typo, as if there should be a space between -include and C:\... but I don't know how to change this. I couldn't find CmdLine.hs, just the interface file CmdLine.hi which yielded no results.
Does anyone have any advice on how to remedy this?
It appears that there should be a space between the -include and the file name.
I created a version of GLUtil-0.9.0.1 that is already preprocessed and should work for you:
https://github.com/erantapaa/GLUtil-0.9.0.1-no-cpp
It assumes you are using GHC 7.10.x or later.
The steps to remove the dependency on CPP were:
files JuicyTextures.hs and ShaderProgram.hs just use CPP to include Control.Applicative for older versions of GHC, so I just commented out those lines. Also remove CPP from the LANGUAGE pragma.
Linear.hs uses CPP to generate code. You can create the pre-processed output with:
gcc -E - < Linear.hs > new-Linear.hs
Then remove lines beginning with a hash (#) and remove CPP from the LANGUAGE pragma.
in GLUtil.cabal comment out/remove the lines:
if impl(ghc >= 7.10.1)
Build-depends: hpp >= 0.3 && < 0.4
GHC-Options: -pgmPhpp -optP--cpp -optP-P
else
Build-tools: cpphs
GHC-Options: -pgmPcpphs -optP--cpp -optP
Related
I try to build qhull from hackage and get the error
fatal error: qhull_ra.h: No such file or directory
2 | #include "qhull_ra.h"
`gcc' failed in phase `C Compiler'. (Exit code: 1)
The file is in the Cdir and the relevant parts of the cabal file are
include-dirs: ./Cdir
C-sources: ./Cdir/libqhull_r.c
, ./Cdir/geom_r.c
, ...
The file qhull_ra.h is not listed as C-sources, because it is a header file.
I did not write the code and are not experienced with including C code into haskell packages. The failure occurs sometimes and sometimes not, but I cannot tell when. What is wrong? I want to upload the package (authorized by the author); what do I have to change to make it compile with cabal install?
I've noticed that cabal install is (since recently) much more strict than cabal build when looking for files. So, I believe here the problem is that your include files are not being picked up by cabal.
I think you can fix that by listing your header files in a includes: field. So at least:
include-dirs: Cdir
includes: qhull_ra.h
c-sources: Cdir/libqhull_r.c
, ...
I'm trying to compile a new Haskell project with Stack, but I'm getting this error message:
$ stack build
WARNING: Ignoring regex-posix's bounds on base (<0 && >=4.3 && <4.16); using base-4.14.1.0.
Reason: trusting snapshot over cabal file dependency information.
regex-posix > configure
regex-posix > Configuring regex-posix-0.96.0.0...
regex-posix > build
regex-posix > Preprocessing library for regex-posix-0.96.0.0..
regex-posix > compiling .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.c failed (exit code 1)
regex-posix > rsp file was: ".stack-work\\dist\\274b403a\\build\\Text\\Regex\\Posix\\hsc5BFC.rsp"
regex-posix > command was: C:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\../mingw/bin\gcc.exe -c .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.c -o .stack-work\dist\274b403a\build\Text\Regex\Posix\Wrap_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dmingw32_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dmingw32_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist\274b403a\build\cbits -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -I.stack-work\dist\274b403a\build\autogen -I.stack-work\dist\274b403a\build\global-autogen -include .stack-work\dist\274b403a\build\autogen\cabal_macros.h -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\bytestring-0.10.12.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\base-4.14.1.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib\integer-gmp-1.0.3.0\include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4\lib/include -IC:\Users\mark\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.4/lib/include/
regex-posix > error: Wrap.hsc:96:10: fatal error: regex.h: No such file or directory
regex-posix > compilation terminated.
regex-posix >
Progress 1/2
-- While building package regex-posix-0.96.0.0 (scroll up to its section to see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.2.1.0_ghc-8.10.4.exe --builddir=.stack-work\dist\274b403a build --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
I don't understand the initial warning. When looking at the regex-posix package's dependencies, it does list base (>=4.3 && <4.16) as a dependency, but where does the <0 come from?
I've set the resolver to LTS 18.0 in stack.yaml:
resolver: lts-18.0
According to the documentation of LTS 18.0, it uses base-4.14.1.0. If the versioning is lexicographic, I'd think that 4.14.1.0 fits the range that regex-posix requires (if we, for a moment, ignore the strange <0 constraint).
Here are the relevant parts of my package.yaml:
dependencies:
- base >= 4.7 && < 5
- regex-posix >= 0.96
library:
source-dirs: src
ghc-options:
- -Wall
My stack version:
$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
I'm on Windows 10.
FWIW, it's not that I care much about regex-posix in itself. In reality, I'm trying to set up a test project, and test-framework depends on regex-posix.
How can I resolve this issue so that I can compile my code?
The error is not about the version, that is just a warning. The real error is about a missing "regex.h" header for the underlying C library. That header is almost always present on posix platforms (like linux), but not on Windows. See https://github.com/haskell-hvr/regex-posix/issues/4
Particularly this comment by Paul Johnson:
Correction to the above: you don't need mingw64. You just need to install with the _regex-posix-clib flag enabled (note the underscore).
With plain cabal: cabal install regex-posix -f _regex-posix-clib
In Stack, add the following to your stack.yaml:
extra-deps:
- regex-posix-clib-2.7
flags:
regex-posix:
_regex-posix-clib: true
In that thread there is also a comment about the <0 version: https://github.com/haskell-hvr/regex-posix/issues/4#issuecomment-699786233
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.
I'm using Ubuntu 14.10 with GHC 7.6.3 and cabal installed via the Ubuntu package installer, and trying to use the Heap data structure, which I naively installed using:
cabal install heap
As soon as I started importing the library into my code, I got the following linking error:
...
Loading package primitive-0.5.0.1 ... linking ... done.
...
Loading package heap-1.0.0 ... linking ... done.
...
Loading package primitive-0.5.2.1 ... linking ... done
...
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
hsprimitive_memset_Word32
whilst processing object file
/home/simon/.cabal/lib/primitive-0.5.2.1/ghc-7.6.3/HSprimitive-0.5.2.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
This answer notionally explains what to do, but the instructions are not specific enough for me to follow.
How do I get Heap to use primitive-0.5.2.1 (I'm assuming that this lightly used library is the one that is out of date), or should I be doing something completely different?
One solution might be to specifically install an earlier version of heap:
cabal install heap-0.6.0
You might have to first unregister heap-1.0.0.
Another option is to blow away your ~/.ghc directory. Of course, you will have to reinstall cabal packages.
I think the best option is to start using cabal sandboxing for your projects.
Edit: heap-1.0.0 contains QuickCheck tests and thus brings in all of the QuickCheck dependencies. To install that version without QuickCheck, try this:
In a new directory, run cabal get heap-1.0.0
cd heap-1.0.0
Edit heap.cabal and remove the Build-Depends: line
Run cabal install
I'm trying to install a package (nymphaea as it happens). This depends on an earlier version of base than the one I have. I'm not keen on downgrading my base libraries, so I'd like to try to just ignore that dependency, and see how things go.
Is there a way to tell cabal to miss out a particular dependency?
Update: After I edit the cabal file, what do I do with it? Cabal doesn't have an obvious way to point it at a file, nor anywhere I can manually put cabal files, as far as I can tell.
[As per below, apparently I should just invoke cabal install in a directory containing the edited cabal file ]
Update 2: Unfortunately, cabal gives me a weird error about package versions being required which I appear to have:
$ cabal install -v --upgrade-dependencies time
Reading available packages...
Resolving dependencies...
In order, the following would be installed:
time-1.2.0.5 (new version)
Extracting
C:\Users\Marcin\AppData\Roaming\cabal\packages\hackage.haskell.org\time\1.2.0.5\time-1.2.0.5.tar.gz
to C:\Users\Marcin\time-1.2.0.54736...
Creating C:\Users\Marcin\time-1.2.0.54736\time-1.2.0.5\dist\setup (and its
parents)
C:\Program Files (x86)\Haskell Platform\2011.2.0.1\bin\ghc.exe --make C:\Users\Marcin\time-1.2.0.54736\time-1.2.0.5\Setu
p.hs -o C:\Users\Marcin\time-1.2.0.54736\time-1.2.0.5\dist\setup\setup.exe -odir C:\Users\Marcin\time-1.2.0.54736\time-1
.2.0.5\dist\setup -hidir C:\Users\Marcin\time-1.2.0.54736\time-1.2.0.5\dist\setup -i -iC:\Users\Marcin\time-1.2.0.54736\
time-1.2.0.5 -package Cabal-1.10.1.0
<command line>: cannot satisfy -package Cabal-1.10.1.0:
Cabal-1.10.1.0-55f781465ee9f32289755ad706c71f0f is unusable due to missing or recursive dependencies:
directory-1.1.0.0-3a2367d72569467a8af8a231656ff1b8 process-1.0.1.5-b3dded8e54a2e13d22af410bdcfafff4
(use -v for more information)
World file is already up to date.
cabal.exe: Error: some packages failed to install:
time-1.2.0.5 failed during the configure step. The exception was:
ExitFailure 1
To follow up on the comments to Don's answer:
First, grab the package from Hackage.
$ cabal unpack nymphaea
Then edit the .cabal file and change base <= 4.1.0.0 to base > 3 && < 5.
$ cd nymphaea-0.3
$ vim nymphaea.cabal
Now, try to install it.
$ cabal install
I got it to work with this change using Haskell Platform 2011.2.0.1 on Ubuntu Natty after installing the required Debian packages.
You must edit the .cabal file associated with the package and remove any constraints on base that you see. Change, for example,
base < 3
to
base >= 3 && < 5
And see if it compiles. If it works, you might bump the version and let the maintainer know. If they don't respond, you might upload the fixed version to Hackage yourself.