[GRASS-dev] Configuring --with-readline doesn't use -lncurses or -ltermcap

Hi, all. I encountered a problem configuring --with-readline A workaround
exists in the mailing list archives, but since the problem still exists
almost 2 years after the workaround was posted, sholl asked me to post it
to the devel list to bring it to your attention.

Problem:
When --with-readline is supplied, configure reports that readline was not
found.

Analysis:
Examining the config.log, the compile of conftest.c includes the
-lreadline flag, but does not include either -lncurses or -ltermcap which
is required for GNU readline. The result is linking errors to the effect
of "undefined reference to `tgetnum'" et al.

Workaround:
Set LDFLAGS in the environment to force -lncurses
http://grass.itc.it/pipermail/grassuser/2005-February/027824.html

Ideal:
Have configure detect whether to use -lncurses or else -ltermcap, and have
it use that flag, so configure will properly link with readline and thus
detect it.

--
HostGIS
Cartographic development and hosting services
707-822-9355
http://www.HostGIS.com/

Gregor Mosheh wrote:

Hi, all. I encountered a problem configuring --with-readline A workaround
exists in the mailing list archives, but since the problem still exists
almost 2 years after the workaround was posted, sholl asked me to post it
to the devel list to bring it to your attention.

Problem:
When --with-readline is supplied, configure reports that readline was not
found.

Analysis:
Examining the config.log, the compile of conftest.c includes the
-lreadline flag, but does not include either -lncurses or -ltermcap which
is required for GNU readline. The result is linking errors to the effect
of "undefined reference to `tgetnum'" et al.

Workaround:
Set LDFLAGS in the environment to force -lncurses

Yuk. That will add a ncurses dependency to every single library and
executable.

http://grass.itc.it/pipermail/grassuser/2005-February/027824.html

Ideal:
Have configure detect whether to use -lncurses or else -ltermcap, and have
it use that flag, so configure will properly link with readline and thus
detect it.

How is it meant to know *which* library to use? Both provide the
necessary functions (as does -ltinfo if you have that library), but
they don't necessarily behave the same (particularly on platforms
other than Linux, where e.g. -ltermcap may actually use the termcap
database while -lncurses may use the terminfo database).

Ideal:
The OS vendor adds the correct library as a dependency of libreadline.

On my system (Gentoo):

$ ldd /lib/libreadline.so
  linux-gate.so.1 => (0xffffe000)
  libncurses.so.5 => /lib/libncurses.so.5 (0xb7f65000)
  libc.so.6 => /lib/libc.so.6 (0xb7e4c000)
  /lib/ld-linux.so.2 (0x80000000)

--with-readline works fine here.

I consider this a WONTFIX until someone comes up with a coherent
answer to the question of how to choose amongst multiple competing
"providers" of tgetent etc.

On a related note: how many people actually feed complex expressions
to r.mapcalc via stdin?

--
Glynn Clements <glynn@gclements.plus.com>

On Fri, 2006-12-22 at 03:02 +0000, Glynn Clements wrote:

Gregor Mosheh wrote:

> Hi, all. I encountered a problem configuring --with-readline A workaround
> exists in the mailing list archives, but since the problem still exists
> almost 2 years after the workaround was posted, sholl asked me to post it
> to the devel list to bring it to your attention.
>
> Problem:
> When --with-readline is supplied, configure reports that readline was not
> found.
>
> Analysis:
> Examining the config.log, the compile of conftest.c includes the
> -lreadline flag, but does not include either -lncurses or -ltermcap which
> is required for GNU readline. The result is linking errors to the effect
> of "undefined reference to `tgetnum'" et al.
>
> Workaround:
> Set LDFLAGS in the environment to force -lncurses

Yuk. That will add a ncurses dependency to every single library and
executable.

> http://grass.itc.it/pipermail/grassuser/2005-February/027824.html
>
> Ideal:
> Have configure detect whether to use -lncurses or else -ltermcap, and have
> it use that flag, so configure will properly link with readline and thus
> detect it.

How is it meant to know *which* library to use? Both provide the
necessary functions (as does -ltinfo if you have that library), but
they don't necessarily behave the same (particularly on platforms
other than Linux, where e.g. -ltermcap may actually use the termcap
database while -lncurses may use the terminfo database).

Ideal:
The OS vendor adds the correct library as a dependency of libreadline.

On my system (Gentoo):

$ ldd /lib/libreadline.so
  linux-gate.so.1 => (0xffffe000)
  libncurses.so.5 => /lib/libncurses.so.5 (0xb7f65000)
  libc.so.6 => /lib/libc.so.6 (0xb7e4c000)
  /lib/ld-linux.so.2 (0x80000000)

--with-readline works fine here.

I consider this a WONTFIX until someone comes up with a coherent
answer to the question of how to choose amongst multiple competing
"providers" of tgetent etc.

FYI, this is what RedHat has to say (from bug tracker):

"There are people who need to link against termcap, and people who need
to link against ncurses. The choice has to be made at compile time for
*their* app, not readline."

On a related note: how many people actually feed complex expressions
to r.mapcalc via stdin?

I have on rare occasion, but I certainly did not require readline to do
so. I don't think the prompt has any real significance anymore. I find
it more useful (and more to GRASS style) to use 'map=expression' and
script it if I need repetition.

I vote to remove readline.

--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785

Brad Douglas wrote:

> How is it meant to know *which* library to use? Both provide the
> necessary functions (as does -ltinfo if you have that library), but
> they don't necessarily behave the same (particularly on platforms
> other than Linux, where e.g. -ltermcap may actually use the termcap
> database while -lncurses may use the terminfo database).
>
> Ideal:
> The OS vendor adds the correct library as a dependency of libreadline.
>
> On my system (Gentoo):
>
> $ ldd /lib/libreadline.so
> linux-gate.so.1 => (0xffffe000)
> libncurses.so.5 => /lib/libncurses.so.5 (0xb7f65000)
> libc.so.6 => /lib/libc.so.6 (0xb7e4c000)
> /lib/ld-linux.so.2 (0x80000000)
>
> --with-readline works fine here.
>
> I consider this a WONTFIX until someone comes up with a coherent
> answer to the question of how to choose amongst multiple competing
> "providers" of tgetent etc.

FYI, this is what RedHat has to say (from bug tracker):

"There are people who need to link against termcap, and people who need
to link against ncurses. The choice has to be made at compile time for
*their* app, not readline."

Right.

One issue is that, if readline was linked against libtermcap (or if
configure added that library to $(READLINELIB)), and the application
needed both libreadline and libcurses, it would end up getting linked
against all three, with the result that libtermcap and libcurses would
clash over tgetent etc. And vice-versa.

On Linux, universally linking against libncurses is reasonably safe,
as that provides a strict superset of the functionality available
through libtermcap and libtinfo without adding any additional
dependencies. The GNU version of all of those libraries all use
terminfo by default with termcap as a fallback, so you get the same
behaviour from all of them.

AFAICT, the only real issue is namespace pollution, i.e. the
executable (or some other library) may export a symbol which clashes
with libcurses but not with libtermcap or libtinfo.

> On a related note: how many people actually feed complex expressions
> to r.mapcalc via stdin?

I have on rare occasion, but I certainly did not require readline to do
so. I don't think the prompt has any real significance anymore. I find
it more useful (and more to GRASS style) to use 'map=expression' and
script it if I need repetition.

FWIW, my usual terminal is an XEmacs shell-mode buffer, so I don't
have any need for readline. I only use xterm for programs which insist
on using curses or ^H/^M tricks (G_percent() is *not* my friend).

I vote to remove readline.

Leaving it in for the cases where it does work is only harmful insofar
as some people just *have* to have --with-everything. Removing it
wouldn't provide any real benefit (other than eliminating the feeling
that someone else is getting something which they aren't).

AFAICT, the only other practical option would be to add a (e.g.)
--with-readline-aux-libs= option so that the user can provide any
additional switches (e.g. --with-readline-aux-libs=-ltermcap).

--
Glynn Clements <glynn@gclements.plus.com>