7

I'm referring to the haskell readline library wrapper to the c readline library.

cabal install readline output below:

$ cabal install readline
Resolving dependencies...
Configuring readline-1.0.1.0...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for GNUreadline.framework... checking for readline... no
checking for tputs in -lncurses... yes
checking for readline in -lreadline... yes
checking for rl_readline_version... yes
checking for rl_begin_undo_group... no
configure: error: readline not found, so this package cannot be built
See `config.log' for more details.
cabal: Error: some packages failed to install:
readline-1.0.1.0 failed during the configure step. The exception was:
ExitFailure 1

I have the c readline library installed via macports (using sudo port install readline), but I still get the same error while trying to install the haskell readline library.

David Miani
  • 14,518
  • 2
  • 47
  • 66

3 Answers3

21

If your MacPorts installation uses the default paths for installed files, try specifying where to look for the C headers and libraries:

cabal install readline --extra-include-dirs=/opt/local/include \
--extra-lib-dirs=/opt/local/lib

Update 2x: On my machine with GNU Readline installed via Homebrew rather than MacPorts, it looks like the configure script for the Haskell readline library needs some non-standard flags to properly find its bearings. If the above doesn't work, try this:

cabal install readline --extra-include-dirs=/opt/local/include \
--extra-lib-dirs=/opt/local/lib \
--configure-option=--with-readline-includes=/opt/local/include \
--configure-option=--with-readline-libraries=/opt/local/lib
acfoltzer
  • 5,588
  • 31
  • 48
  • 3
    Thanks, I got it working. I used the command: `sudo port install readline +universal` to install readline, and the command `cabal install readline --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib --configure-option=--with-readline-includes=/opt/local/include --configure-option=--with-readline-libraries=/opt/local/lib` to install the haskell readline library. – David Miani Nov 28 '11 at 05:10
  • Of course; it needs to have both to actually link against once `configure` has run. Updated to reflect the final mouthful of a command – acfoltzer Nov 28 '11 at 05:15
  • 9
    The readline formula is keg only, therefore I had to add full path to the keg like so: `cabal install readline --extra-include-dirs=/usr/local/Cellar/readline/6.2.4/include/ --extra-lib-dirs=/usr/local/Cellar/readline/6.2.4/lib/ --configure-option=--with-readline-includes=/usr/local/Cellar/readline/6.2.4/include/ --configure-option=--with-readline-libraries=/usr/local/Cellar/readline/6.2.4/lib/` – liborw Nov 23 '12 at 20:54
  • 1
    I needed : cabal install readline --extra-include-dirs=/usr/local/Cellar/readline/6.2.4/include/ --extra-lib-dirs=/usr/local/Cellar/readline/6.2.4/lib/ --configure-option=--with-readline-includes=/usr/local/Cellar/readline/6.2.4/include/readline --configure-option=--with-readline-libraries=/usr/local/Cellar/readline/6.2.4/lib/ – i-blis Apr 01 '13 at 18:15
  • Has anyone been successful doing this with `stack install`? – ITA Jul 29 '17 at 15:20
1

I ended up following the instructions here http://fp.okeefecreations.com/2010/08/installing-haskell-bindings-to-readline.html in order to get it working on my homebrew installation of readline. The only modification I had to make was to adjust the version of readline listed in the path.

I know this is a similar solution to acfoltzer's but I don't have the rep to add a comment there or either I just can't figure out how to comment. :)

sonstone
  • 697
  • 6
  • 9
  • 1
    $ cabal install readline --configure-option=--with-readline-libraries="/usr/local/Cellar/readline/6.2.4/lib" --configure-option=--with-readline-includes="/usr/local/Cellar/readline/6.2.4/include" For latest – The Internet Oct 15 '12 at 07:12
  • The link in your answer is broken. – Gregory Putzel Jan 27 '15 at 00:29
0

If you used brew, here's the command you can use which is very similar to the above and you have to replace the version I'm stated with the one you have on your system i.e. 7.0.5

cabal install readline --extra-include-dirs=/usr/local/Cellar/readline/7.0.5/include --extra-lib-dirs=/usr/local/Cellar/readline/7.0.5/lib --configure-option=--with-readline-includes=/usr/local/Cellar/readline/7.0.5/include --configure-option=--with-readline-libraries=/usr/local/Cellar/readline/7.0.5/lib
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135