Trouble compiling program using the readline library.

Hi: in the info page for readline library I read

 -- Function: void rl_variable_dumper (int readable)
     Print the readline variable names and their current values to
     `rl_outstream'.  If READABLE is non-zero, the list is formatted in
     such a way that it can be made part of an `inputrc' file and
     re-read.

And wrote a little C program:

semoi@server:~/work$ cat dumpall.c                      
# Compile with 'gcc -Wall -lreadline -o dumpall dumpall.c'

#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>

extern void rl_variable_dumper(int john);

main(){
    rl_variable_dumper(0);
}
       
semoi@server:~/work$

Compiling,

semoi@server:~/work$ gcc -o dumpall dumpall.c -lreadline
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tputs'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tgoto'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tgetflag'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `UP'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tgetent'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tgetnum'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `PC'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `tgetstr'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../lib64/libreadline.so: undefined reference to `BC'
collect2: error: ld returned 1 exit status
semoi@server:~/work$ 

you see what I get. What am I doing wrong?

Add -lncurses

1 Like