Can't to install QuickCheck with cabal 'can't find -lgmp'

Hi, I am trying to install QuickCheck with cabal on Fedora 38. I installed haskell via the dnf package manager. The Glorious Glasgow Haskell Compilation System, version 9.2.8 & cabal-install version 3.6.2.0 compiled using version 3.6.2.0 of the Cabal library .

Running the command: $ cabal install QuickCheck

Resolving dependencies...
Build profile: -w ghc-9.2.8 -O1
In order, the following will be built (use -v for more details):
 - splitmix-0.1.0.4 (lib) (requires build)
 - random-1.2.1.1 (lib) (requires build)
 - QuickCheck-2.14.3 (lib) (requires build)
Starting     splitmix-0.1.0.4 (lib)
Building     splitmix-0.1.0.4 (lib)

Failed to build splitmix-0.1.0.4.
Build log (
/home/klock/.cabal/logs/ghc-9.2.8/splitmix-0.1.0.4-2080e76bdba4cdfe864671097a51e89a482f579f30120640379c6e933078fc7c.log
):
Configuring library for splitmix-0.1.0.4..
Preprocessing library for splitmix-0.1.0.4..
Building library for splitmix-0.1.0.4..
[1 of 4] Compiling Data.Bits.Compat ( src-compat/Data/Bits/Compat.hs, dist/build/Data/Bits/Compat.o, dist/build/Data/Bits/Compat.dyn_o )
[2 of 4] Compiling System.Random.SplitMix.Init ( src/System/Random/SplitMix/Init.hs, dist/build/System/Random/SplitMix/Init.o, dist/build/System/Random/SplitMix/Init.dyn_o )
[3 of 4] Compiling System.Random.SplitMix ( src/System/Random/SplitMix.hs, dist/build/System/Random/SplitMix.o, dist/build/System/Random/SplitMix.dyn_o )
[4 of 4] Compiling System.Random.SplitMix32 ( src/System/Random/SplitMix32.hs, dist/build/System/Random/SplitMix32.o, dist/build/System/Random/SplitMix32.dyn_o )
/usr/bin/ld.gold: error: cannot find -lgmp
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
cabal: Failed to build splitmix-0.1.0.4 (which is required by
QuickCheck-2.14.3). See the build log above for details.

This is the output of the log file:

$ cat splitmix-0.1.0.4-2080e76bdba4cdfe864671097a51e89a482f579f30120640379c6e933078fc7c.log                         
Configuring library for splitmix-0.1.0.4..
Preprocessing library for splitmix-0.1.0.4..
Building library for splitmix-0.1.0.4..
[1 of 4] Compiling Data.Bits.Compat ( src-compat/Data/Bits/Compat.hs, dist/build/Data/Bits/Compat.o, dist/build/Data/Bits/Compat.dyn_o )
[2 of 4] Compiling System.Random.SplitMix.Init ( src/System/Random/SplitMix/Init.hs, dist/build/System/Random/SplitMix/Init.o, dist/build/System/Random/SplitMix/Init.dyn_o )
[3 of 4] Compiling System.Random.SplitMix ( src/System/Random/SplitMix.hs, dist/build/System/Random/SplitMix.o, dist/build/System/Random/SplitMix.dyn_o )
[4 of 4] Compiling System.Random.SplitMix32 ( src/System/Random/SplitMix32.hs, dist/build/System/Random/SplitMix32.o, dist/build/System/Random/SplitMix32.dyn_o )
/usr/bin/ld.gold: error: cannot find -lgmp
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

Your help is very appreciated. Thanks.

You’re missing the Gnu MP bignum library. I’m not sure of the naming in Fedora but that’s what you need to install

1 Like

Thank you very much I thought I had it installed as I had gmp installed as a package however it turns out there were two related packages gmp-devel gmp-c++ which I didn’t have and after installing them I have been able to install it though with a warning.
`$ cabal install QuickCheck
Resolving dependencies…
Build profile: -w ghc-9.2.8 -O1
In order, the following will be built (use -v for more details):

  • splitmix-0.1.0.4 (lib) (requires build)
  • random-1.2.1.1 (lib) (requires build)
  • QuickCheck-2.14.3 (lib) (requires build)
    Starting splitmix-0.1.0.4 (lib)
    Building splitmix-0.1.0.4 (lib)
    Installing splitmix-0.1.0.4 (lib)
    Completed splitmix-0.1.0.4 (lib)
    Starting random-1.2.1.1 (lib)
    Building random-1.2.1.1 (lib)
    Installing random-1.2.1.1 (lib)
    Completed random-1.2.1.1 (lib)
    Starting QuickCheck-2.14.3 (lib)
    Building QuickCheck-2.14.3 (lib)
    Installing QuickCheck-2.14.3 (lib)
    Completed QuickCheck-2.14.3 (lib)
    Warning:
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: Installation might not be completed as desired! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    The command “cabal install [TARGETS]” doesn’t expose libraries.
  • You might have wanted to add them as dependencies to your package. In this
    case add “QuickCheck” to the build-depends field(s) of your package’s .cabal
    file.
  • You might have wanted to add them to a GHC environment. In this case use
    “cabal install --lib QuickCheck”. The “–lib” flag is provisional: see
    https://github.com/haskell/cabal/issues/6481 for more information.
    `

Yeah, you’re not really supposed to use cabal install any more. Instead you make a .cabal file for your package and just depend on QuickCheck. Then cabal build of your package will automatically install QuickCheck (if it isn’t already).

If you just want to play around with QuickCheck in ghci you can do cabal repl --build-depends QuickCheck.

1 Like

See First steps - GHCup for more information on the best practices.

1 Like