Cabal: `gcc' failed in phase `Linker'. (Exit code: 1)

Created on 15 Jul 2017  路  4Comments  路  Source: haskell/cabal

It seems I'm not able to install anything via cabal install, this has worked before. :)

cabal --version
cabal-install version 1.22.8.0
using version 1.22.7.0 of the Cabal library

ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2

gcc --version
gcc (GCC) 7.1.1 20170630

ld --version
GNU ld (GNU Binutils) 2.28.0.20170506

Host OS: Arch Linux

 cabal install clay
Resolving dependencies...
Configuring clay-0.12.2...
Failed to install clay-0.12.2
Build log ( /home/chris/.cabal/logs/clay-0.12.2.log ):
cabal: Error: some packages failed to install:
clay-0.12.2 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/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_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
cabal install turtle
Resolving dependencies...
Configuring base-prelude-1.2.0.1...
Configuring hostname-1.0...
Configuring managed-1.0.5...
Configuring optional-args-1.0.1...
Failed to install base-prelude-1.2.0.1
Build log ( /home/chris/.cabal/logs/base-prelude-1.2.0.1.log ):
Failed to install hostname-1.0
Build log ( /home/chris/.cabal/logs/hostname-1.0.log ):
Failed to install managed-1.0.5
Build log ( /home/chris/.cabal/logs/managed-1.0.5.log ):
Failed to install optional-args-1.0.1
Build log ( /home/chris/.cabal/logs/optional-args-1.0.1.log ):
cabal: Error: some packages failed to install:
base-prelude-1.2.0.1 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/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_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
foldl-1.3.0 depends on base-prelude-1.2.0.1 which failed to install.
hostname-1.0 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/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_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
managed-1.0.5 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/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_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
optional-args-1.0.1 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/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_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)
turtle-1.3.6 depends on optional-args-1.0.1 which failed to install.
vector-builder-0.3.1 depends on base-prelude-1.2.0.1 which failed to install.

Most helpful comment

Removed .stack-work and added a module to the cabal exposed-modules... And it's all working now.

All 4 comments

Looks like some kind of system configuration problem. Can you post a -v3 log that shows the relevant command line invocations?

https://wiki.archlinux.org/index.php/Haskell#Problems_with_linking
https://www.reddit.com/r/haskell/comments/6nleqc/arch_haskell/

Following the advice in the wiki seems to have solved the cabal install turtle issues, but surprisingly I'm not able to build packages using stack build now. Though I've just had a package upgrade of GHC...

stack build
ScalesDemo-0.1.0.0: configure (exe)
ScalesDemo-0.1.0.0: build (exe)
Log files have been written to: /home/chris/Projects/Haskell/Chris/Scales/.stack-work/logs/

--  While building package ScalesDemo-0.1.0.0 using:
      /home/chris/.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 exe:ScalesDemo --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/chris/Projects/Haskell/Chris/Scales/.stack-work/logs/ScalesDemo-0.1.0.0.log

    Configuring ScalesDemo-0.1.0.0...
    Preprocessing executable 'ScalesDemo' for ScalesDemo-0.1.0.0...
    Linking .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/ScalesDemo/ScalesDemo ...
    /home/chris/Projects/Haskell/Chris/Scales/.stack-work/install/x86_64-linux-nopie/lts-8.6/8.0.2/lib/x86_64-linux-ghc-8.0.2/Scales-0.1.0.0-3gqrGiLcRTr2DGLrXp7puD/libHSScales-0.1.0.0-3gqrGiLcRTr2DGLrXp7puD.a(Scales.o):(.text+0x3e59): undefined reference to `Scaleszm0zi1zi0zi0zm3gqrGiLcRTr2DGLrXp7puD_ModelsziDB_runQuerySingle1_info'
    /home/chris/Projects/Haskell/Chris/Scales/.stack-work/install/x86_64-linux-nopie/lts-8.6/8.0.2/lib/x86_64-linux-ghc-8.0.2/Scales-0.1.0.0-3gqrGiLcRTr2DGLrXp7puD/libHSScales-0.1.0.0-3gqrGiLcRTr2DGLrXp7puD.a(Scales.o):(.data.rel.ro+0x230): undefined reference to `Scaleszm0zi1zi0zi0zm3gqrGiLcRTr2DGLrXp7puD_ModelsziDB_runQuerySingle1_closure'
    collect2: error: ld returned 1 exit status
    `gcc' failed in phase `Linker'. (Exit code: 1)

Removed .stack-work and added a module to the cabal exposed-modules... And it's all working now.

Was this page helpful?
0 / 5 - 0 ratings