[질문]readline 함수 사용질문.
글쓴이: chxooi / 작성시간: 수, 2004/03/17 - 4:39오후
#include<stdio.h>
int main(void)
{
char *buffer;
char * s;
s = readline(buffer);
return 0;
}
물론 다 짠건 아니지만 readline 을 쓰기 위해 위와 같은 코드를 구현했습니다.
그런데 compile 을 하면,
gcc -o test test.c
/tmp/ccXxIWq9.o: In function 'main':
/tmp/ccXxIWq9.o:(.text+0x14):undefined reference to 'readline'
collect 2: ld returned 1 exit status
로 나옵니다.
undefined reference 라...readline 을 사용할 수 없는건가요?
아니면 원래 GNU C 에서 지원하는 default 함수가 아닌가요?
man 페이지에는 나와 있던데...양이 많아서 꼼꼼히 읽진 않았지만, 저렇게 쓰면 사용되어야 할꺼 같은데 에러 내용자체가 아예 참조가 안되는거 같아서 질문 드립니다.
답변 부탁 드려여..
Forums:
[code:1]#include <readline/readline.h
위의 두개 파일도 include 하셔야 합니다.
근데..
두개의 헤더 더했더니...
/tmp/cc01NZ78.o:In function 'main':
/tmp/cc01NZ78.o(.txt+0x14):undefined reference to 'readline'
collect2: ld returned 1 exit status
로 나오는군요.. 쩝..
(root로) ldconfiggcc -o readlinetest te
(root로) ldconfig
gcc -o readlinetest test.c -lreadline
이렇게도 한번 해보세요.. : ) 참고로 테스트파일의 이름은 test로 하지 않으시는 것이 좋습니다.
gcc -o abcd test.c -lreadline 로 수행하니까.
gcc -o abcd test.c -lreadline
로 수행하니까...
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../llibreadline.so:undefined reference to 'tgetnum'
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../llibreadline.so:undefined reference to 'tgoto'
등이 쭈우욱~~~나오네요....
구글로 검색해봤더니 -ltermcap이나 -lncurses 둘 중 하나도
구글로 검색해봤더니 -ltermcap이나 -lncurses 둘 중 하나도 같이 붙여주셔야 한다고 나오는 것 같았습니다.
Google is your friend. :)
댓글 달기