免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6803 | 回复: 3
打印 上一主题 下一主题

[求助]curses无法通过编译 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-11 09:59 |只看该作者 |倒序浏览
近来在学习linux编程,如下一段代码不能通过编译。
#include<unistd.h>
#include<curses.h>

int
main()
{
    initscr();

    move(5,15);
    printw("%s","Hello World");
    refresh();
    sleep(2);

    endwin();
    exit(0);
}


出错信息如下:
hy@hy-laptop:~$ gcc -o curses curses.c
curses.c: In function ‘main’:
curses.c:15: warning: incompatible implicit declaration of built-in function ‘exit’
/tmp/cc6Ldbmz.o: In function `main':
curses.c.text+0x12): undefined reference to `initscr'
curses.c.text+0x17): undefined reference to `stdscr'
curses.c.text+0x2f): undefined reference to `wmove'
curses.c.text+0x43): undefined reference to `printw'
curses.c.text+0x4: undefined reference to `stdscr'
curses.c.text+0x50): undefined reference to `wrefresh'
curses.c.text+0x61): undefined reference to `endwin'
collect2: ld returned 1 exit status

[ 本帖最后由 weiqiboy 于 2007-10-11 10:00 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-10-11 10:02 |只看该作者
所需模块都安装了 的,下面所有模块均已安装。系统是ubuntu 7
libncurses5                The ncurses shared libraries
libncurses5-dev                Development environment
libncurses5-dbg                Debugging libraries

libncursesw5                The ncurses shared libraries, with wide character
                        support
libncursesw5-dev        Development environment for libncursesw5
libncursesw5-dbg        Debugging libraries for libncursesw5

ncurses-bin                Various small applications (clear, reset, tic, etc.)
ncurses-base                Standard terminal entries
ncurses-term                All the rest of the terminal entries

论坛徽章:
0
3 [报告]
发表于 2007-10-11 10:09 |只看该作者
gcc -o curses curses.c  -lcurses  这样就可以了

论坛徽章:
0
4 [报告]
发表于 2007-10-11 10:20 |只看该作者
确实如此,谢谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP