readline AWOL?

Kurt Wall kwall at kurtwerks.com
Tue Nov 18 08:57:57 PST 2008


On Mon, Nov 17, 2008 at 08:40:25PM +0000, Jorge Almeida wrote:
> Hello, C-wise people,
>
> Can someone understand this?
>
> 	$ cat readtest.c
> 	#include <stdio.h>
> 	#include <readline/history.h>
> 	#include <readline/readline.h>
> 	#define MAINPROMPT ">"
> 	int main(int argc, char *argv[])
> 	{
> 	                char *lp;
> 	                lp=readline(MAINPROMPT);
> 	                return 0;
> 	}
> 	$ gcc readtest.c
> 	/tmp/cc88uLvp.o: In function `main':
> 	readtest.c:(.text+0x19): undefined reference to `readline'
> 	collect2: ld returned 1 exit status

You have to link against libreadline:

$ gcc readtest.c -lreadline

Kurt



More information about the Linux-users mailing list