Results 1 to 9 of 9

Thread: Readline command error

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Readline command error

    Hi guys,
    I wrote a code something like this


    Qt Code:
    1. Code:
    2. #include <stdio.h>
    3. #include <readline/readline.h>
    4. #include <readline/history.h>
    5.  
    6. int main()
    7. {
    8. char* p = readline("Enter a password:");
    9. printf("You entered:%s", p);
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 
    I save the file as-->
    pass.c
    I compile it as-->
    cc pass.c -l readline

    I get so many errors as shown

    Qt Code:
    1. Code:
    2. g++ -o testncursors main.o -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib
    3. /usr/lib/libreadline.a -lqt-mt -lXext -lX11 -lm
    4. /usr/lib/libreadline.a(display.o)(.text+0x1d7): In function `cr':
    5. : undefined reference to `tputs'
    6. /usr/lib/libreadline.a(display.o)(.text+0x243): In function `_rl_move_vert':
    7. : undefined reference to `tputs'
    8. /usr/lib/libreadline.a(display.o)(.text+0x290): In function `_rl_move_vert':
    9. : undefined reference to `tputs'
    10. /usr/lib/libreadline.a(display.o)(.text+0x30a): In function
    11. `_rl_clear_to_eol':
    12. : undefined reference to `tputs'
    13. /usr/lib/libreadline.a(display.o)(.text+0x6e0): In function
    14. `_rl_clear_screen':
    15. : undefined reference to `tputs'
    16. /usr/lib/libreadline.a(display.o)(.text+0xbc9): more undefined
    17. references to `tputs' follow
    18. /usr/lib/libreadline.a(display.o)(.text+0x1a2d): In function `update_line':
    19. : undefined reference to `tgoto'
    20. /usr/lib/libreadline.a(display.o)(.text+0x1a45): In function `update_line':
    21. : undefined reference to `tputs'
    22. /usr/lib/libreadline.a(display.o)(.text+0x1c03): In function `update_line':
    23. : undefined reference to `tputs'
    24. /usr/lib/libreadline.a(display.o)(.text+0x1dbd): In function `update_line':
    25. : undefined reference to `tputs'
    26. /usr/lib/libreadline.a(display.o)(.text+0x1e04): In function `update_line':
    27. : undefined reference to `tputs'
    28. /usr/lib/libreadline.a(display.o)(.text+0x1e75): In function `update_line':
    29. : undefined reference to `tputs'
    30. /usr/lib/libreadline.a(display.o)(.text+0x1ef3): In function `update_line':
    31. : undefined reference to `tgoto'
    32. /usr/lib/libreadline.a(display.o)(.text+0x1f0a): In function `update_line':
    33. : undefined reference to `tputs'
    34. /usr/lib/libreadline.a(display.o)(.text+0x33d7): In function `rl_redisplay':
    35. : undefined reference to `tputs'
    36. /usr/lib/libreadline.a(terminal.o)(.text+0x1f6): In function
    37. `_rl_backspace':
    38. : undefined reference to `tputs'
    39. /usr/lib/libreadline.a(terminal.o)(.text+0x2b9): In function `rl_ding':
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Readline command error

    tputs is part of curses library, so I assume that you need to link with it as well (-lncurses).

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Readline command error

    Quote Originally Posted by wysota View Post
    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Readline command error

    Try -ltermcap (works for me, although -lncurses works as well)

  5. The following user says thank you to wysota for this useful post:

    vermarajeev (2nd March 2007)

  6. #5
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Readline command error

    Quote Originally Posted by wysota View Post
    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.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Readline command error

    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.

  8. #7
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Readline command error

    Quote Originally Posted by wysota View Post
    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

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Readline command error

    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

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Readline command error

    BTW. On Unix: man 3 getpass

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.