I want compile install readline library on Ubuntu.
I do the following:
wget http://git.savannah.gnu.org/cgit/readline.git/snapshot/readline-8.0.tar.gz
tar -zxvf readline-8.0.tar.gz
cd readline-8.0
./configure --prefix=`pwd`/readline
make
make install
It's right but when I use -lreadline
option, I get error like this:
readline/lib/libreadline.so: undefined reference to `tputs'
readline/lib/libreadline.so: undefined reference to `tgoto'
readline/lib/libreadline.so: undefined reference to `tgetflag'
readline/lib/libreadline.so: undefined reference to `UP'
readline/lib/libreadline.so: undefined reference to `tgetent'
readline/lib/libreadline.so: undefined reference to `tgetnum'
readline/lib/libreadline.so: undefined reference to `PC'
readline/lib/libreadline.so: undefined reference to `tgetstr'
I want to know what wrong I did and why and what to do?
I'll appreciate it if you help me.
Obviously you are missing to link against a library that readline
relies on. On my system I get
$ readelf --dynamic --symbols --wide /usr/lib64/libreadline.so.7.0 | fgrep tputs
17: 0000000000000000 0 FUNC GLOBAL DEFAULT UND tputs
i.e. tputs
is an external reference in the readline
code.
EDIT: the library would be libtinfo
:
$ readelf --dynamic --symbols --wide /usr/lib64/libtinfo.so.6 | fgrep tputs
199: 0000000000019a30 151 FUNC GLOBAL DEFAULT 12 tputs
245: 00000000000195f0 930 FUNC GLOBAL DEFAULT 12 tputs_sp
So the solution would be to use -lreadline -ltinfo
.
In general I would suggest not to compile libraries yourself, but instead install the -dev(el)
packages provided by your Linux distribution. Then you can use e.g. pkg-config
command to automatically discover the correct C flags and linker options for a library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With