linux学习记录7 - 解决错误fatal error: ncurses.h

近期打算学习ncurse图形界面,在网络上找到了一个Ncurses tutorial..

编译里面的 00-01_box.c产生了如下错误:

zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ vi box.c
zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ gcc box.c 
box.c:1: fatal error: ncurses.h: No such file or directory
compilation terminated.

原因是缺少libncurses5-dev包

zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ su
Password: 
root@zenos-virtual-machine:/home/zenos/workspace/linux_study/ncourse#apt-get install libncurses5-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done

查看已安装包列表中是否有libncurses5-dev

zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ dpkg -l libncurses5-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                 Version         Architecture    Description
+++-====================-===============-===============-==============================================
ii  libncurses5-dev:amd6 6.1-1ubuntu1.18 amd64           developer's libraries for ncurses

重新编译并加入参数-lncurses,成功!

zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ gcc box.c -lncurses
zenos@zenos-virtual-machine:~/workspace/linux_study/ncourse$ ls
a.out  box.c

运行a.out,效果


linux学习记录7 - 解决错误fatal error: ncurses.h_第1张图片

你可能感兴趣的:(linux学习记录7 - 解决错误fatal error: ncurses.h)