haskell / haskeline

A Haskell library for line input in command-line programs.
https://hackage.haskell.org/package/haskeline
BSD 3-Clause "New" or "Revised" License
221 stars 75 forks source link

haskeline does not compile on systems with libncurses, but without libtinfo #16

Closed JasonGross closed 8 years ago

JasonGross commented 9 years ago

When I try to cabal install haskeline, I get

Preprocessing library haskeline-0.7.1.3...
/usr/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
linking
dist/dist-sandbox-7d9f4d88/build/System/Console/Haskeline/Directory_hsc_make.o
failed (exit code 1)

Apparently, libncurses and libtinfo used to be a single package, libncurses. Haskeline should fall back to -lncurses if libtinfo is missing but libncurses is present.

Work-around: After much debugging, the internet suggested symlinking libtinfo.so* to libncurses.so*. Because I have no root on the machine I'm using, I had to do this in a local folder, ~/.local64/lib, and then add ~/.local64/lib to LD_LIBRARY_PATH and LIBRARY_PATH (alternatively, pass cabal install the options --gcc-options="-L$(readlink -f ~/.local64/lib) -Wl,-L$(readlink -f ~/.local64/lib)" --ghc-options="-L$(readlink -f ~/.local64/lib)").

judah commented 9 years ago

Hm, that's strange, thanks for the report. The terminfo package is supposed to only link against libtinfo if it can find it during the configure stage; otherwise it should use lib(n)curses. For example, I don't think libtinfo exists on my mac, but terminfo/haskeline work fine. What operating system/distro/version of GHC are you using?

Can you try reinstalling the terminfo package (which is what's actually introducing the library dependency)? If it still fails, please do the following: download a local copy of terminfo from Hackage, run "configure", and send me the output files "config.log" and "terminfo.buildinfo"; I'll take a look and see what's going on.

JasonGross commented 9 years ago
$ uname -a
Linux cagnode13 3.2.0-0.bpo.4-amd64 #1 SMP Debian 3.2.35-2~bpo60+1 x86_64 GNU/Linux
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.4
$ LD_LIBRARY_PATH="" ghc --version
/afs/csail.mit.edu/u/j/jgross/.local64/lib/ghc-7.8.4/bin/ghc: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

Note: I was unable to get a ghc bindist installed without doing the symlinking and adding the path to libtinfo.so.5 to LD_LIBRARY_PATH. On make install, I got

/afs/csail.mit.edu/u/j/jgross/.local64/lib/ghc-7.8.4/bin/ghc-pkg:
error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
make[1]: *** [install_packages] Error 127

The following works

$ cd /tmp
$ rm -rf bar
$ mkdir bar
$ cd bar
$ cabal sandbox init
Writing a default package environment file to /tmp/bar/cabal.sandbox.config
Creating a new sandbox at /tmp/bar/.cabal-sandbox
$ LIBRARY_PATH="" cabal install --reinstall --force-reinstalls terminfo
...
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for setupterm in -ltinfo... no
checking for setupterm in -lncursesw... no
checking for setupterm in -lncurses... yes
configure: creating ./config.status
config.status: creating terminfo.buildinfo
configure: WARNING: unrecognized options: --with-compiler, --with-gcc
Building terminfo-0.4.0.0...
Preprocessing library terminfo-0.4.0.0...
...
In-place registering terminfo-0.4.0.0...
Creating package registration file: /tmp/pkgConf-terminfo-0.4.032738.0
Installing library in
/tmp/bar/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/terminfo-0.4.0.0
Registering terminfo-0.4.0.0...
Installed terminfo-0.4.0.0
$ LIBRARY_PATH="" cabal install haskeline
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/haskeline-0.7.1.3-1014/haskeline-0.7.1.3/dist/dist-sandbox-45689551/setup/setup.hs, /tmp/ha
skeline-0.7.1.3-1014/haskeline-0.7.1.3/dist/dist-sandbox-45689551/setup/Main.o )
Linking /tmp/haskeline-0.7.1.3-1014/haskeline-0.7.1.3/dist/dist-sandbox-45689551/setup/setup ...
Configuring haskeline-0.7.1.3...
Building haskeline-0.7.1.3...
Preprocessing library haskeline-0.7.1.3...
...
In-place registering haskeline-0.7.1.3...
Creating package registration file: /tmp/pkgConf-haskeline-0.7.11014.3
Installing library in
/tmp/bar/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/haskeline-0.7.1.3
Registering haskeline-0.7.1.3...
Installed haskeline-0.7.1.3
judah commented 8 years ago

I'm closing this issue since it doesn't sound like a problem with haskeline specifically, but feel free to re-open if you have suggestions of what the haskeline or terminfo packages could do differently.