PDA

View Full Version : Readline command error



vermarajeev
2nd March 2007, 11:35
Hi guys,
I wrote a code something like this



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

int main()
{
char* p = readline("Enter a password:");
printf("You entered:%s", p);
return 0;
}I save the file as-->
pass.c
I compile it as-->
cc pass.c -l readline

I get so many errors as shown


Code:
g++ -o testncursors main.o -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib
/usr/lib/libreadline.a -lqt-mt -lXext -lX11 -lm
/usr/lib/libreadline.a(display.o)(.text+0x1d7): In function `cr':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x243): In function `_rl_move_vert':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x290): In function `_rl_move_vert':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x30a): In function
`_rl_clear_to_eol':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x6e0): In function
`_rl_clear_screen':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0xbc9): more undefined
references to `tputs' follow
/usr/lib/libreadline.a(display.o)(.text+0x1a2d): In function `update_line':
: undefined reference to `tgoto'
/usr/lib/libreadline.a(display.o)(.text+0x1a45): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x1c03): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x1dbd): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x1e04): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x1e75): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x1ef3): In function `update_line':
: undefined reference to `tgoto'
/usr/lib/libreadline.a(display.o)(.text+0x1f0a): In function `update_line':
: undefined reference to `tputs'
/usr/lib/libreadline.a(display.o)(.text+0x33d7): In function `rl_redisplay':
: undefined reference to `tputs'
/usr/lib/libreadline.a(terminal.o)(.text+0x1f6): In function
`_rl_backspace':
: undefined reference to `tputs'
/usr/lib/libreadline.a(terminal.o)(.text+0x2b9): In function `rl_ding':These errors are just a part. There are still many

The library is linked but I dont know what is the problem???? Please help... I'm eagerly waiting for a reply.

wysota
2nd March 2007, 11:50
tputs is part of curses library, so I assume that you need to link with it as well (-lncurses).

vermarajeev
2nd March 2007, 12:08
tputs is part of curses library, so I assume that you need to link with it as well (-lncurses).


I tried that too but get the same error...I dont know what is the problem..Is readline working on your system...

Waiting eagerly

wysota
2nd March 2007, 13:02
Try -ltermcap (works for me, although -lncurses works as well)

vermarajeev
2nd March 2007, 13:32
Try -ltermcap (works for me, although -lncurses works as well)

Wonderful!!!!! It works....

I will not say that you have many children or you should earn more money as I say in one of the post but I can definately tell that if anyone have any problems (not personal) please contact the only GURU of qtcenter and that is WYSOTA....

Thanks a lot.

wysota
2nd March 2007, 13:49
I don't consider myself a guru despite the title under my nickname and there are surely people as fit for answering questions as I am, but thank you anyway :)

Especially that I answered your question based on the manual page for tputs and trial and error.

vermarajeev
2nd March 2007, 14:49
I don't consider myself a guru despite the title under my nickname and there are surely people as fit for answering questions as I am, but thank you anyway :)

Especially that I answered your question based on the manual page for tputs and trial and error.

Yes I know Jacek too is my favourite...He too is awesome!!!!!

Anyway, I'm encountering another problem with readline(cost char*). It displays the correct text whatever I type but what if I want to see the text inform of '*'...ie the user enters text and but sees only '*'. Same as we prompt for password.

Example--:
Enter password: ***** The actual '*' value is 'hello'...

Will readline provide that functionality...If not what is the alternate means to do that. I know ncursers is another option but I dont know how to use it.

Waiting eagerly

wysota
2nd March 2007, 14:57
It probably will but you probably have to use some additional/different functions to obtain this. I suggest you consult the readline manual.

http://tiswww.case.edu/~chet/readline/rluserman.html

wysota
2nd March 2007, 15:07
BTW. On Unix: man 3 getpass