Linux C语言打印格式的头文件的设定
近来在学习 linux 编程,如下一段代码不能通过编译。
出错信息如下:
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 编程,如下一段代码不能通过编译。
#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 这样就可以了