[Slackbuilds-users] 'AC_CHECK_LIB([readline]' fails on 14.2

B Watson yalhcru at gmail.com
Sat Jan 27 20:09:08 UTC 2018

On 1/27/18, Nate Bargmann <n0nb at n0nb.us> wrote:
> checking for readline in -lreadline... no
> configure: error: libreadline not found
> Here is what is recorded in 'config.log':
> configure:12811: checking for readline in -lreadline
> configure:12836: gcc -o conftest -g -O2   conftest.c -lreadline   >&5
> /usr/lib/gcc/i586-slackware-linux/5.3.0/../../../libreadline.so: undefined
> reference to `tputs'
> /usr/lib/gcc/i586-slackware-linux/5.3.0/../../../libreadline.so: undefined
> reference to `tgoto'
> <....>

These symbols are defined in libncurses. Normally when anything links
with readline, it also links with ncurses... you could probably have
figured this out yourself, by reading the man page for tputs (it tells
you it's part of curses anyway, which would have been a strong hint).

(I just re-read what I wrote above, and it sounds kinda smarmy... it
isn't meant that way, it's supposed to be helpful & educational. I hate
just giving an answer, would rather give the reasoning behind it.)

You can fix the problem in lxi-tools by adding LIBS="-lncurses" to the
configure command. With standard SBo template, it would look like:

./configure \
  --prefix=/usr \
  <...other options here...>

When I run configure this way, I still can't build lxi-tools since I
don't have the lxi library it depends on, but I do get:

checking for readline in -lreadline... yes
checking for lxi_connect in -llxi... no
configure: error: liblxi not found

...so it'll probably build fine if liblxi is installed.

Interestingly, this isn't just a problem for lxi-tools. Anything that
tries to link with -lreadline but not -lncurses will fail in the same
way on 14.2:

$ cat hello.c
#include <stdio.h>

int main(int argc, char **argv) {
	printf("hello world\n");
	return 0;
$ gcc -lreadline -ohello hello.c
undefined reference to `tputs'
undefined reference to `tgoto'
$ gcc -lreadline -lncurses -ohello hello.c
$ ./hello
hello world

If you look at libreadline:

$ ldd /usr/lib64/libreadline.so
	linux-vdso.so.1 (0x00007ffdb9fc3000)
	libc.so.6 => /lib64/libc.so.6 (0x00002b79a2820000)
	/lib64/ld-linux-x86-64.so.2 (0x000055581e85b000)

...libncurses isn't a hard dependency (though I suspect it should be).

On -current, libncurses has been split in two (libncurses and libtinfo), and
readline is linked with libtinfo:

# ldd /usr/lib/libreadline.so
	linux-gate.so.1 (0xb7fa9000)
	libtinfo.so.6 => /usr/lib/libtinfo.so.6 (0xb7f3b000)
	libc.so.6 => /lib/libc.so.6 (0xb7d4c000)
	/lib/ld-linux.so.2 (0xb7fab000)

...and using -lreadline without -lncurses (or -ltinfo) works fine:

# gcc -lreadline -ohello hello.c
# ./hello
hello world
# ldd ./hello
	linux-gate.so.1 (0xb7f2a000)
	libreadline.so.7 => /usr/lib/libreadline.so.7 (0xb7ea8000)
	libc.so.6 => /lib/libc.so.6 (0xb7cf1000)
	libtinfo.so.6 => /usr/lib/libtinfo.so.6 (0xb7ccd000)
	/lib/ld-linux.so.2 (0xb7f2c000)

Clear as mud, yes?

More information about the SlackBuilds-users mailing list