바뀜

둘러보기로 가기 검색하러 가기
4,165 바이트 추가됨 ,  2017년 8월 29일 (화) 22:00
새 문서: 작성일자: 2015년 10월 27일 작성자: westporch == NCurses 다운로드 == ftp://ftp.gnu.org/pub/gnu/ncurses/ 에서 최신 버전의 NCurses를 다운받습니다. 2015.12....
작성일자: 2015년 10월 27일
작성자: westporch

== NCurses 다운로드 ==
ftp://ftp.gnu.org/pub/gnu/ncurses/ 에서 최신 버전의 NCurses를 다운받습니다. 2015.12.27 기준으로 최신 버전인 [ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz ncurses-6.0]을 설치하겠습니다.

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads# wget ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz
--2015-12-27 14:47:12-- ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.0.tar.gz
=> ‘ncurses-6.0.tar.gz’
Resolving ftp.gnu.org (ftp.gnu.org)... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/gnu/ncurses ... done.
==> SIZE ncurses-6.0.tar.gz ... 3131891
==> PASV ... done. ==> RETR ncurses-6.0.tar.gz ... done.
Length: 3131891 (3.0M) (unauthoritative)

ncurses-6.0.tar.gz 100%[===========================================>] 2.99M 1.50MB/s in 2.0s

2015-12-27 14:47:18 (1.50 MB/s) - ‘ncurses-6.0.tar.gz’ saved [3131891]

root@RaspberryPi:~/Downloads#
</syntaxhighlight>


== NCurses 설치 ==

다운 받은 ncurses 파일의 압축을 해제합니다.

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads# ls
ncurses-6.0.tar.gz
root@RaspberryPi:~/Downloads# tar zxvf ncurses-6.0.tar.gz
root@RaspberryPi:~/Downloads# ls
ncurses-6.0 ncurses-6.0.tar.gz
root@RaspberryPi:~/Downloads#
</syntaxhighlight>

압축을 해제한 ncurses-6.0 폴더로 이동합니다.

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads# cd ncurses-6.0
root@RaspberryPi:~/Downloads/ncurses-6.0#
</syntaxhighlight>

=== ./configure ===

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads/ncurses-6.0# ./configure
(...생략...)
Appending rules for normal model (form: ticlib+termlib+ext_tinfo+base+ext_funcs)
Appending rules for debug model (form: ticlib+termlib+ext_tinfo+base+ext_funcs)
Appending rules for normal model (test: ticlib+termlib+ext_tinfo+base+ext_funcs)
Appending rules for debug model (test: ticlib+termlib+ext_tinfo+base+ext_funcs)
creating headers.sh

** Configuration summary for NCURSES 6.0 20150808:

extended funcs: yes
xterm terminfo: xterm-new

bin directory: /usr/bin
lib directory: /usr/lib
include directory: /usr/include
man directory: /usr/share/man
terminfo directory: /usr/share/terminfo

root@RaspberryPi:~/Downloads/ncurses-6.0#
</syntaxhighlight>

=== make ===

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads/ncurses-6.0# make
make[1]: Leaving directory '/root/Downloads/ncurses-6.0/misc'
root@RaspberryPi:~/Downloads/ncurses-6.0#
</syntaxhighlight>

=== make install ===

<syntaxhighlight lang="">
root@RaspberryPi:~/Downloads/ncurses-6.0# make install
installing std
installing stdcrt
installing vt100
installing vt300
/usr/bin/install -c ncurses-config /usr/bin/ncurses6-config
make[1]: Leaving directory '/root/Downloads/ncurses-6.0/misc'
root@RaspberryPi:~/Downloads/ncurses-6.0#
</syntaxhighlight>


== 설치 확인 ==

NCurses 라이브러리를 이용하여 Hello World를 출력하는 프로그램을 만들어 보겠습니다.

=== Hello World 프로그램 ===

<syntaxhighlight lang="">
root@RaspberryPi:~/NCurses# vi hello.c
</syntaxhighlight>

hello.c 소스

<syntaxhighlight lang="c" line>
//hello.c
#include <ncurses.h>

int main()
{
initscr(); // Start curses mode
printw("Hello World"); // Print Hello World
refresh(); // Print it on to the real screen
getch(); // Wait for user input
endwin(); // End curses mode

return 0;
}
</syntaxhighlight>

=== 컴파일 ===

<syntaxhighlight lang="">
root@RaspberryPi:~/NCurses# gcc -o hello hello.c -lncurses
root@RaspberryPi:~/NCurses#
</syntaxhighlight>

=== 실행 ===

<syntaxhighlight lang="">
root@RaspberryPi:~/NCurses# ls
hello hello.c
root@RaspberryPi:~/NCurses# ./hello
</syntaxhighlight>

''hello'' 파일을 실행하면 Hello World가 출력됩니다.

<syntaxhighlight lang="">
Hello World
</syntaxhighlight>

둘러보기 메뉴