I am quite new to Haskell programming and in the process of creating my first proper project using Cabal I encountered an error.
I followed this tutorial when structuring the project. However, when I got to the step where I had to enter cabal install -j
I got the following error:
cabal: Entering directory '.'
Configuring CabalTest-0.1.0.0...
Building CabalTest-0.1.0.0...
Preprocessing executable 'CabalTest' for CabalTest-0.1.0.0...
Linking dist/dist-sandbox-fe048ba8/build/CabalTest/CabalTest ...
/usr/bin/ld: cannot find -lHSbase-4.9.1.0
/usr/bin/ld: cannot find -lHSinteger-gmp-1.0.0.1
/usr/bin/ld: cannot find -lHSghc-prim-0.5.0.0
/usr/bin/ld: cannot find -lHSrts
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
cabal: Leaving directory '.'
I have tried to run cabal install base integer-gmp ghc-prim rts --reinstall
, to which it answers that it cannot find rts. When I modified the command to exclude rts it instead outputted this:
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0 (only already installed instances can
be used)
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Running cabal update
did not help and changing the ~/.cabal/config file to include user-install: False
did not do anything either.
I solved the issue. It turns out the problem was due to the GHC package I had got through pacman (I am using arch linux). The problem here is that whenever GHC tries to link to any libraries it does so statically. However, the pacman package for GHC doesn't include any of the static libraries needed. To solve the issue, I had to install a separate package called ghc-static which included all static libraries.