你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下基于curses的一个简单例程

[日期:2007-11-28] 来源:Linux公社  作者:heyunhuan513 [字体:大 中 小]
以上程序存储为test.c文件;
 
Makefile文件的编写:
 
#all : test.c
test : test.c
    gcc $^ -o $@ -I/usr/include -L/usr/lib -lncurses
clean :
    -rm *.o
 
注意紫色部分代码,若不添加其代码会出现一下错误信息
 
gcc test.c -o test
/tmp/ccKYmGQf.o: In function `initial':
test.c:(.text+0x7): undefined reference to `initscr'
test.c:(.text+0xc): undefined reference to `cbreak'
test.c:(.text+0x11): undefined reference to `nonl'
test.c:(.text+0x16): undefined reference to `noecho'
test.c:(.text+0x1b): undefined reference to `stdscr'
test.c:(.text+0x2b): undefined reference to `intrflush'
test.c:(.text+0x30): undefined reference to `stdscr'
test.c:(.text+0x40): undefined reference to `keypad'
test.c:(.text+0x45): undefined reference to `stdscr'
test.c:(.text+0x4d): undefined reference to `wrefresh'
/tmp/ccKYmGQf.o: In function `main':
test.c:(.text+0x78): undefined reference to `stdscr'
test.c:(.text+0xc0): undefined reference to `wborder'
test.c:(.text+0xc5): undefined reference to `stdscr'
test.c:(.text+0xdd): undefined reference to `wattr_on'
test.c:(.text+0xe2): undefined reference to `stdscr'
test.c:(.text+0xfa): undefined reference to `wmove'
test.c:(.text+0x104): undefined reference to `stdscr'
test.c:(.text+0x11c): undefined reference to `waddnstr'
test.c:(.text+0x121): undefined reference to `stdscr'
test.c:(.text+0x139): undefined reference to `wattr_off'
test.c:(.text+0x13f): undefined reference to `stdscr'
test.c:(.text+0x155): undefined reference to `wmove'
test.c:(.text+0x15a): undefined reference to `stdscr'
test.c:(.text+0x162): undefined reference to `wgetch'
test.c:(.text+0x20e): undefined reference to `stdscr'
test.c:(.text+0x224): undefined reference to `wmove'
test.c:(.text+0x22e): undefined reference to `stdscr'
test.c:(.text+0x23e): undefined reference to `waddch'
test.c:(.text+0x245): undefined reference to `endwin'
test.c:(.text+0x25a): undefined reference to `stdscr'
test.c:(.text+0x266): undefined reference to `waddch'
test.c:(.text+0x280): undefined reference to `stdscr'
test.c:(.text+0x296): undefined reference to `wmove'
collect2: ld returned 1 exit status
make: *** [test] Error 1
 
当出现上述错误信息的时候,需要在Makefile文件中编译的时候添加以下语句
 
# gcc test.c -o test -I/usr/include -L/usr/lib -lncurses
 
最后执行./test 即可看到所有执行的结果linux
相关资讯       curses  Linux知识 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款