컴파일러에게 libconio의 존재를 알릴 방법이 없나요?
글쓴이: noblepylon / 작성시간: 화, 2008/06/24 - 5:25오후
콘솔용 지뢰찾기 게임을 간단하게 만들었습니다.
키 입력을 받으려고 getch()함수를 사용했고요.
T = getch();
switch(T) {
case ESCAPE:
return 0;
case 0:
case 224:
break;
case LEFT:
Refresh(Coord(0, -1)); break;
case RIGHT:
Refresh(Coord(0, 1)); break;
case UP:
Refresh(Coord(-1, 0)); break;
case DOWN:
Refresh(Coord(1, 0)); break;
case 'f': // 'f' key: open the cell
IsOpened[CursorPos.row][CursorPos.col] = true;
num_opened++;
Refresh(Coord(0, 0));
break;
case 'd':
// 'd' key: mark the cell "dangerous," i.e. put the flag.
IsOpened[CursorPos.row][CursorPos.col] = true;
Map[CursorPos.row][CursorPos.col] = FLAG;
Refresh(Coord(0, 0));
break;
default: // invalid key
Play(C, Sixteenth); Play(C, Sixteenth); Play(C, Sixteenth); break;
}이걸 이제 리눅스상에서 컴파일하려고 했습니다.
마침 SourceForge에 libconio라는 프로젝트가 있길래 설치했습니다. 듣기로는 이게 conio.h의 리눅스 구현인것 같더군요.
그런데 libconio를 설치했음에도 불구하고 자꾸만 다음과 같은 에러가 납니다.
main.cpp:(.text+0x512)||undefined reference to `getch()'|
컴파일러에게 libconio의 존재를 알릴 방법이 없나요?
Forums:


굳이 getch를 써야할
굳이 getch를 써야할 필요가 있는진 모르겠지만, '컴파일러'에 대해 물어보실땐, 사용하시는 '컴파일러명'이나 컴파일할때 이용한 '컴파일 옵션'을 적어주셔야 답변받기 쉬울것입니다.
일반적으로 유닉스계열에선 -l라이브러리이름 옵션으로 링커에게 넘겨주도록 지정할수 있습니다.
이경우는 -lconio처럼 적어보시면 될것같네요.
Code::Blocks IDE를 사용하고 있습니다.
Code::Blocks IDE를 사용하고 있습니다. 컴파일은 gcc를 이용하도록 돼 있고요.
그런데 '컴파일 옵션'이란건 어디에서 설정해야 하는지 도저히 감을 잡을수가 없군요-_-;
---
"The truth will make you free."(John 8:32)
"I am the way, and the truth, and the life: no one comes to the Father but through Me."(John 14:6)
---
“내게 능력주시는 자 안에서 내가 모든 것을 할 수 있느니라.”(빌립보서 4:13)
sourceforge에 있는
sourceforge에 있는 libconio는 C++을 고려하지 않고 만든 C 라이브러리입니다.
헤더를 고쳐서 다시 컴파일하거나, curses library를 쓰기 바랍니다.
헤더에 extern "C" { ... }를 추가하면 될 듯 하네요.
--
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://cinsk.github.io/cfaqs/
댓글 달기