Thread: NetBSD 1.4.2/i386 needs to link psql with -ltermcap

NetBSD 1.4.2/i386 needs to link psql with -ltermcap

From
Giles Lean
Date:
[ Slightly edited take #2: I wasn't subscribed (again :-() to the
  -bugs list.  Moderator -- you can kill any postings of mine in the
  queue, if you care to. :-]

Hi,

Today I built postgresql-7.1beta6 on NetBSD-1.4.2/i386, which uses
a.out binary format.  (NetBSD 1.5/i386 uses ELF.)

I found that psql needs to be linked with -ltermcap or else psql will
fail with a runtime error when used interactively:

$ psql ...
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

/usr/libexec/ld.so: Undefined symbol "_tgetent" called from psql:/usr/lib/libedit.so.2.2 at 0x400892ac

I added -ltermcap to the "LIBS = ..." line in Makefile.global and
rebuilt psql after which it worked without problems.

Builds on NetBSD-1.5/i386 and NetBSD-1.5/alpha included -ltermcap in
LIBS automatically.

Thanks to those who enabled libedit -- history editing is nice.

Regards,

Giles

Re: NetBSD 1.4.2/i386 needs to link psql with -ltermcap

From
Peter Eisentraut
Date:
Giles Lean writes:

> Today I built postgresql-7.1beta6 on NetBSD-1.4.2/i386, which uses
> a.out binary format.  (NetBSD 1.5/i386 uses ELF.)
>
> I found that psql needs to be linked with -ltermcap or else psql will
> fail with a runtime error when used interactively:

> /usr/libexec/ld.so: Undefined symbol "_tgetent" called from psql:/usr/lib/libedit.so.2.2 at 0x400892ac

This should be detected by configure.  E.g., on my system I get

| checking for readline... yes (-lreadline -ltermcap)

(-lreadline and -ledit are equivalent for computational purposes).
config.log shows:

| configure:3143: checking for readline
| configure:3165: gcc -o conftest -O2 -g     conftest.c -lreadline  1>&5
[ tries without termcap]
| /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined reference to `tgetnum'
[snip]
| configure:3165: gcc -o conftest -O2 -g     conftest.c -lreadline -ltermcap  1>&5
[ tries with termcap, success ]

Can you check around these areas why it doesn't behave as expected?

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/

Re: NetBSD 1.4.2/i386 needs to link psql with -ltermcap

From
Giles Lean
Date:
Peter Eisentraut wrote

> This should be detected by configure.  E.g., on my system I get
>
> | checking for readline... yes (-lreadline -ltermcap)
>
> (-lreadline and -ledit are equivalent for computational purposes).

On NetBSD-1.4.2 is that the link test works with -ledit, and indeed
psql built without -ltermcap will even run non-interactively (I loaded
a database with it) but it fails when running interactively.

config.log:

configure:3143: checking for readline
configure:3165: gcc -o conftest -O2 -pipe     conftest.c -lreadline  1>&5
ld: -lreadline: no match
collect2: ld returned 1 exit status
configure: failed program was:
#line 3154 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char readline();

int main() {
readline()
; return 0; }
configure:3165: gcc -o conftest -O2 -pipe     conftest.c -ledit  1>&5
configure:3192: checking for library containing using_history
configure:3210: gcc -o conftest -O2 -pipe     conftest.c -ledit  1>&5
...

It would be nicer if the link failed. :-(

Actually running the program above:

/usr/libexec/ld.so: Undefined symbol "_tgetent" called from
conf:/usr/lib/libed\ it.so.2.2 at 0x4002d2ac

ldd doesn't show problems:

conf:
        -ledit.2 => /usr/lib/libedit.so.2.2 (0x4001b000)
        -lc.12 => /usr/lib/libc.so.12.40 (0x4002f000)

I'm now out of my depth with both configure and linker behaviour. :-(

Regards,

Giles

Re: NetBSD 1.4.2/i386 needs to link psql with -ltermcap

From
Peter Eisentraut
Date:
Giles Lean writes:

> char readline();
>
> int main() {
> readline()
> ; return 0; }
> configure:3165: gcc -o conftest -O2 -pipe     conftest.c -ledit  1>&5
> configure:3192: checking for library containing using_history
> configure:3210: gcc -o conftest -O2 -pipe     conftest.c -ledit  1>&5
> ...
>
> It would be nicer if the link failed. :-(
>
> Actually running the program above:
>
> /usr/libexec/ld.so: Undefined symbol "_tgetent" called from
> conf:/usr/lib/libed\ it.so.2.2 at 0x4002d2ac

This looks to be an oddly behaving linker.  Maybe this is a better
question for a netbsd user forum.

> ldd doesn't show problems:
>
> conf:
>         -ledit.2 => /usr/lib/libedit.so.2.2 (0x4001b000)
>         -lc.12 => /usr/lib/libc.so.12.40 (0x4002f000)

How about ldd libedit?

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/