f



readline problem [libreadline.so: undefined reference to...]

I'm running RedHat 7.1 and I can't get the readline author's example program
to compile (nor any other readline-using program).  Any suggestions?  Here
are the error messages:

[root@db:/home/jake/weber/unix/readline-example]$ gcc -lreadline rl.c
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tgetnum'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tgoto'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tgetflag'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `BC'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tputs'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `PC'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tgetent'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `UP'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
reference to `tgetstr'
collect2: ld returned 1 exit status


0
Jason
7/13/2003 11:30:16 PM
comp.unix.programmer 10828 articles. 0 followers. kokososo56 (349) is leader. Post Follow

4 Replies
2598 Views

Similar Articles

[PageSpeed] 7

"Jason" <jake1138@NO.SPAM.yahoo.com> writes:

> I'm running RedHat 7.1 and I can't get the readline author's example program
> to compile (nor any other readline-using program).  Any suggestions?  Here
> are the error messages:
> 
> [root@db:/home/jake/weber/unix/readline-example]$ gcc -lreadline rl.c
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tgetnum'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tgoto'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tgetflag'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `BC'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tputs'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `PC'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tgetent'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `UP'
> /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so: undefined
> reference to `tgetstr'
> collect2: ld returned 1 exit status

RTFM.           gcc -lreadline -termcap rl.c

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy              ROT13: ybergv@cq.vasa.vg
0
Maurizio
7/14/2003 5:38:53 AM
Maurizio Loreti <mlo@foobar.it> wrote in message news:<rmy8z1u0pe.fsf@mlinux.pd.infn.it>...

> gcc -lreadline -termcap rl.c

Better make that "gcc rl.c -lreadline -ltermcap".
The order of sources and libraries matters, and so does spelling.

Cheers,
0
ppluzhnikov
7/14/2003 8:53:24 PM
"Maurizio Loreti" <mlo@foobar.it> wrote in message
news:rmy8z1u0pe.fsf@mlinux.pd.infn.it...
> "Jason" <jake1138@NO.SPAM.yahoo.com> writes:
>
> > I'm running RedHat 7.1 and I can't get the readline author's example
program
> > to compile (nor any other readline-using program).  Any suggestions?
Here
> > are the error messages:
> >
> > [root@db:/home/jake/weber/unix/readline-example]$ gcc -lreadline rl.c
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tgetnum'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tgoto'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tgetflag'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `BC'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tputs'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `PC'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tgetent'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `UP'
> > /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../libreadline.so:
undefined
> > reference to `tgetstr'
> > collect2: ld returned 1 exit status
>
> RTFM.           gcc -lreadline -termcap rl.c
>
> -- 
> Maurizio Loreti
http://www.pd.infn.it/~loreti/mlo.html
> Dept. of Physics, Univ. of Padova, Italy              ROT13:
ybergv@cq.vasa.vg

And what FM would that be?

I can compile this just fine on a Debian system with just -lreadline, but
not on either of the RedHat systems that I've tried.  I can add -ltermcap
or -lncurses and either one will allow it to compile though.  Anyone care to
shed some light on why?  What does readline have to do with termcap or
ncurses?  By the way, thanks for your responses.

--
Jason
[ jake1138 AT yahoo DOT com ]


0
Jason
7/15/2003 5:21:41 AM
"Jason" <jake1138@NO.SPAM.yahoo.com> wrote in message news:<bf0316$sk7$1@terabinaries.xmission.com>...

> And what FM would that be?

This doesn't appear to be documented in the info pages ;-(

You could have figured it out, though:

$ nm -AD /usr/lib/lib*.so 2>/dev/null | grep ' tgetnum'
/usr/lib/libcurses.so:00029140 T tgetnum
/usr/lib/libncurses.so:00029140 T tgetnum
/usr/lib/libreadline.so:         U tgetnum
/usr/lib/libtermcap.so:00001e60 T tgetnum

> I can compile this just fine on a Debian system with just -lreadline, but
> not on either of the RedHat systems that I've tried.  I can add -ltermcap
> or -lncurses and either one will allow it to compile though.  Anyone care to
> shed some light on why?  

Probably because libreadline.so on Debian has a dynamic dependency on
libtermcap.so or libncurses.so, while on RedHat it doesn't.

Run "ldd your_exe" to find which libreadline.so it uses, then 
"ldd /path/to/libreadline.so" on both systems, and compare the results.

> What does readline have to do with termcap or ncurses? 

It needs to redraw your screen (well, just the line on which you are typing),
and position your cursor. That's precisely what lib{curses,termcap} do.
Typing "info termcap" will tell you more.

Cheers,
0
ppluzhnikov
7/15/2003 4:41:29 PM
Reply: