linux的文件操作

linux 下C语言打印 头文件设定  

2011-04-25 10:10:34|  分类: 程序 |  标签: |字号 订阅

Linux C语言打印格式的头文件的设定
近来在学习 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

解决办法:
安装ncurses所需的如下模块:(用sudo apt-get install filename )
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


gcc -o curses curses.c  -lcurses  这样就可以了


 

linux下C语言 undefined reference to stdscr wgetch wrefresh mvwprintw 解决

分类: C语言x C语言学习笔记   65人阅读  评论(0)  收藏  举报

gcc test.c -o text -l curses搞定 就是编译的时候 加个参数 -l curses 就可以了

或者最后加上参数  -I/usr/include -L/usr/lib -lncurses


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值