Chinaunix

标题: [求助]curses无法通过编译 [打印本页]

作者: weiqiboy    时间: 2007-10-11 09:59
标题: [求助]curses无法通过编译
近来在学习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 编辑 ]
作者: weiqiboy    时间: 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
作者: cccccc    时间: 2007-10-11 10:09
gcc -o curses curses.c  -lcurses  这样就可以了
作者: weiqiboy    时间: 2007-10-11 10:20
确实如此,谢谢。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2