So I tried this simple program to test a Text-screen based program on my Ubuntu 12.04:
mrinal@ms-dell:~/C_Progs$ cat screen1.c
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
int main()
{
initscr();
move(5,15);
printw("%s","Hello World");
refresh();
sleep(5);
endwin();
exit(EXIT_SUCCESS);
}
When I try to compile it using the Text-screen library system curses, I get the following error:
mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses
screen1.c:3:20: fatal error: curses.h: No such file or directory
compilation terminated.
Turns out I dont have the curses.h header file (nor the new ncurses.h)
mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*curs*
ls: cannot access *curs*: No such file or directory
This means the packages for curses (and/or ncurses) library are missing. To fix this, I did this:
mrinal@ms-dell:~/C_Progs$ sudo apt-get install libncurses5-dev libncursesw5-dev
[sudo] password for mrinal:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
...
After this operation, 2,971 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main libtinfo-dev amd64 5.9-4 [103 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ precise/main libncurses5-dev amd64 5.9-4 [222 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ precise/main libncursesw5-dev amd64 5.9-4 [255 kB]
Fetched 581 kB in 9s (64.0 kB/s)
...
Setting up libtinfo-dev (5.9-4) ...
Setting up libncurses5-dev (5.9-4) ...
Setting up libncursesw5-dev (5.9-4) ...
mrinal@ms-dell:~/C_Progs$
After this, the curses header file is now available in my /usr/include directory:
mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*cur*
-rw-r--r-- 1 root root 6582 Nov 18 2011 /usr/include/cursesapp.h
-rw-r--r-- 1 root root 27630 Nov 18 2011 /usr/include/cursesf.h
-rw-r--r-- 1 root root 76291 Nov 18 2011 /usr/include/curses.h
...
-rw-r--r-- 1 root root 7304 Nov 18 2011 /usr/include/cursslk.h
-rw-r--r-- 1 root root 3925 Nov 18 2011 /usr/include/ncurses_dll.h
lrwxrwxrwx 1 root root 8 Nov 18 2011 /usr/include/ncurses.h -> curses.h
/usr/include/ncursesw:
total 352
-rw-r--r-- 1 root root 6591 Nov 18 2011 cursesapp.h
-rw-r--r-- 1 root root 27648 Nov 18 2011 cursesf.h
-rw-r--r-- 1 root root 93685 Nov 18 2011 curses.h
-rw-r--r-- 1 root root 19522 Nov 18 2011 cursesm.h
...
-rw-r--r-- 1 root root 40299 Nov 18 2011 term.h
-rw-r--r-- 1 root root 12534 Nov 18 2011 tic.h
-rw-r--r-- 1 root root 3108 Nov 18 2011 unctrl.h
And the program compiles successfully:
mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses
mrinal@ms-dell:~/C_Progs$ cat screen1.c
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
int main()
{
initscr();
move(5,15);
printw("%s","Hello World");
refresh();
sleep(5);
endwin();
exit(EXIT_SUCCESS);
}
When I try to compile it using the Text-screen library system curses, I get the following error:
mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses
screen1.c:3:20: fatal error: curses.h: No such file or directory
compilation terminated.
Turns out I dont have the curses.h header file (nor the new ncurses.h)
mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*curs*
ls: cannot access *curs*: No such file or directory
This means the packages for curses (and/or ncurses) library are missing. To fix this, I did this:
mrinal@ms-dell:~/C_Progs$ sudo apt-get install libncurses5-dev libncursesw5-dev
[sudo] password for mrinal:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
...
After this operation, 2,971 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main libtinfo-dev amd64 5.9-4 [103 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ precise/main libncurses5-dev amd64 5.9-4 [222 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ precise/main libncursesw5-dev amd64 5.9-4 [255 kB]
Fetched 581 kB in 9s (64.0 kB/s)
...
Setting up libtinfo-dev (5.9-4) ...
Setting up libncurses5-dev (5.9-4) ...
Setting up libncursesw5-dev (5.9-4) ...
mrinal@ms-dell:~/C_Progs$
After this, the curses header file is now available in my /usr/include directory:
mrinal@ms-dell:~/C_Progs$ ls -l /usr/include/*cur*
-rw-r--r-- 1 root root 6582 Nov 18 2011 /usr/include/cursesapp.h
-rw-r--r-- 1 root root 27630 Nov 18 2011 /usr/include/cursesf.h
-rw-r--r-- 1 root root 76291 Nov 18 2011 /usr/include/curses.h
...
-rw-r--r-- 1 root root 7304 Nov 18 2011 /usr/include/cursslk.h
-rw-r--r-- 1 root root 3925 Nov 18 2011 /usr/include/ncurses_dll.h
lrwxrwxrwx 1 root root 8 Nov 18 2011 /usr/include/ncurses.h -> curses.h
/usr/include/ncursesw:
total 352
-rw-r--r-- 1 root root 6591 Nov 18 2011 cursesapp.h
-rw-r--r-- 1 root root 27648 Nov 18 2011 cursesf.h
-rw-r--r-- 1 root root 93685 Nov 18 2011 curses.h
-rw-r--r-- 1 root root 19522 Nov 18 2011 cursesm.h
...
-rw-r--r-- 1 root root 40299 Nov 18 2011 term.h
-rw-r--r-- 1 root root 12534 Nov 18 2011 tic.h
-rw-r--r-- 1 root root 3108 Nov 18 2011 unctrl.h
mrinal@ms-dell:~/C_Progs$ gcc screen1.c -o ans -lcurses
And executes successfully too.
mrinal@ms-dell:~/C_Progs$ ./ans
No comments:
Post a Comment