Hakyll Error Watching and Building

Hi,

I have a blog I use Hakyll for and up until recently it has worked fine. Now, though, when I try - cabal new-run site watch - I get the following error:

ld: warning: ignoring duplicate libraries: '-lm', '-lz'
ld: Undefined symbols:
  _iconv, referenced from:
      _hs_iconv in libHSbase-4.17.2.1.a[6](iconv.o)
  _iconv_close, referenced from:
      _hs_iconv_close in libHSbase-4.17.2.1.a[6](iconv.o)
  _iconv_open, referenced from:
      _hs_iconv_open in libHSbase-4.17.2.1.a[6](iconv.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.4.8: `gcc' failed in phase `Linker'. (Exit code: 1)

The error is *identical* I think to `cabal new-run site build`:
ld: warning: ignoring duplicate libraries: '-lm', '-lz'
ld: Undefined symbols:
  _iconv, referenced from:
      _hs_iconv in libHSbase-4.17.2.1.a[6](iconv.o)
  _iconv_close, referenced from:
      _hs_iconv_close in libHSbase-4.17.2.1.a[6](iconv.o)
  _iconv_open, referenced from:
      _hs_iconv_open in libHSbase-4.17.2.1.a[6](iconv.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.4.8: `gcc' failed in phase `Linker'. (Exit code: 1)


Does anyone know how to fix this linker error?

The GCC version I am using is Apple clang version 15.0.0 (clang-1500.1.0.2.5).

1 Like

Although you are using Cabal (the tool), this reminds me of a Stack issue: Build 2.11.1 from source fails on macOS with linker error to symbol `iconv` · Issue #6182 · commercialhaskell/stack · GitHub. The input there from @turboMaCk may help you.

1 Like

Sorry I missed the notification.

This indeed looks exactly like issue I’ve described here Build 2.11.1 from source fails on macOS with linker error to symbol `iconv` · Issue #6182 · commercialhaskell/stack · GitHub

root of the problem is that you’ve some software that packages non apple version of libiconv. The symbol names between apple version and other versions are different. On mac ghc expects to be linking into apple provided versions of lib but the non apple one are found and there the problem starts.

Please check to linked comment for more details. If you have some more specific questions please tag me. It’s hard to give exact solution because I can’t inspect your computer. But look for things like homebrew packages, anaconda or other python distributions etc. All of these might break this for you. Or use nix based builds to prevent these issues.