banner
Tenifs

Tenifs

雄关漫道真如铁,而今迈步从头越。
github
follow
zhihu
email

Cannot find ncurses.h header file

Introduction#

GNU ncurses is a software API for controlling writing to the console screen on Unix, Linux, and other operating systems. The ncurses library can be used to create text-based user interfaces (TUI) on Linux or similar Unix systems.

ncurses (new curses) is a programming library that provides a series of functions to facilitate the generation of text-based user interfaces.

In fact, we are not unfamiliar with ncurses itself, as the following well-known software have used ncurses:

  • vim
  • emacs
  • lynx
  • screen
  • ......

Installation and Usage#

Using Ubuntu 22.04 as an example

sudo apt-get install libncurses5-dev

After installation, we can test if it was successful using the following code

#include <string.h>
#include <ncurses.h>


int main(int argc, char* argv[]) {

    initscr();
    raw();
    noecho();
    curs_set(0);

    char* s = "Hello, Liu Yuhe!";

    // Print the string in the center of the screen
    mvprintw(LINES / 2, (COLS - strlen(s)) / 2, "%s", s);
    refresh();

    getch();
    endwin();

    return 0;
}
gcc test.c -o test -lncurses

image

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.