[Haskell-beginners] Error when running `cabal install cabal-install`

Clemens Lang cal at macports.org
Thu Apr 23 14:56:09 PDT 2015


----- On 23 Apr, 2015, at 22:46, Peng Yu pengyu.ut at gmail.com wrote:

> Indeed, I uninstalled libiconv by running the following command.
> sudo port uninstall --follow-dependents libiconv
> Then, `cabal install cabal-install` runs without a problem.
> Hi MacPorts Users, Is there better solution to this problem? Please
> see the original question regarding the conflict of MacPorts and
> Haskell. (I don't what to use haskell from MacPorts as I want to keep
> updated with the latest version of Haskell.)
> https://mail.haskell.org/pipermail/beginners/2015-April/015214.html

The headers for the copy of libiconv installed with MacPorts make this
rename transparent for the end user application, because they ship with
the appropriate #defines to change the symbols to the names they use in
the MacPorts build of the library (which is vanilla upstream, btw; we
don't actively change the symbol names).

So if you get these link errors, the problem almost always is that you
adjusted your library search path, but not the corresponding header
search path and you're actually compiling against Apple's iconv.h but
MacPorts libiconv.dylib (or vice-versa).

In your case, the missing symbol is iconv_open, which is named
libiconv_open in MacPorts' copy:

 $> nm /opt/local/lib/libiconv.dylib | grep -E 'iconv_open$'
 00000000000011d0 T _libiconv_open

If the code you're compiling includes iconv.h (I'm not sure whether the
Haskell code actually does that or just hardcodes the symbol name, I
didn't bother checking), and you're not passing -DLIBICONV_PLUG, this
should just work out of the box:

 $> grep -A1 -B1 -E '\#define iconv_open ' /opt/local/include/iconv.h
 #define iconv_open libiconv_open

Long story short: Try
 $> cabal install --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib

P.S.: If anybody wants to port cabal2nix[1] into a cabal2port (or write
something similar from scratch) to help fixing the situation of lacking
Haskell packages in MacPorts in a generic way, that would be very welcome.
I only have so much time to maintain packages and writing a Haskell
port is easy to automate – I just didn't have any time to do it yet.

[1] https://github.com/NixOS/cabal2nix
Clemens Lang

More information about the macports-users mailing list