Results 1 to 5 of 5

Thread: an error with curses.h library in gcc

  1. #1
    Join Date
    Jan 2011
    Beans
    3

    an error , curses.h library in gcc

    hi there

    i am new to this forum

    i am working on a course project,it is simplified Pacman .

    i used to get "char"s from input w/o pushing enter button , in windows compilers there is a library named conio.h but it is not standard
    so i installed a similar(maybe!) library curses.h
    using this command:

    Code:
    sudo apt-get install libncurses5
    and i included to my c++ code:

    Code:
    ...
    #include<curses.h>
    
    ...
    
    int loop()
    {
    char a;
    a=getch();
    cout<<a<<endl;
    ...
    and I get two errors:
    undefined reference to 'stdscr'
    undefined reference to 'stdscrwgetch'


    what should I do?
    Last edited by asixbabak; January 17th, 2011 at 08:34 PM.

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: an error with curses.h library in gcc

    have you linked with libcurses?

    g++ -lcurses
    or -lncurses if you use ncurses instead of curses

  3. #3
    Join Date
    Jun 2009
    Location
    Boston, MA
    Beans
    9

    Re: an error with curses.h library in gcc

    Do you have the development package installed?

    sudo apt-get install libncurses5-dev

    "This package contains the header files, static libraries
    and symbolic links that developers using ncurses will need."

  4. #4
    Join Date
    Jan 2011
    Beans
    3

    Re: an error with curses.h library in gcc

    yes
    i have installed curses precisely
    but still got the problem

  5. #5
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: an error with curses.h library in gcc

    are you sure you need stdscrwgetch?
    as far as I can tell this function does not exist with this name in curses.

    getch gets translated to: wgetch(stdscr) on my system
    both these symbols exist in libcurses.
    Code:
    nm --dynamic /usr/lib/libncurses.so  | grep -E "wgetch|stdscr"
    0000000000243db0 B stdscr
    0000000000016d40 T wgetch
    maybe a typo?

Tags for this Thread

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
  •