- 论坛徽章:
- 0
|
- #include <stdlib.h>
- #include <stdio.h>
- //#include "/usr/include/readline/readline.h"
- //#include "/usr/include/readline/history.h"
- #include <readline/history.h>
- #include <readline/readline.h>
- #define MAX_HISTORY_NO 3
- int
- main(void)
- {
- char *prompt = getenv("PS2");
- char *line = NULL;
- int lineSize = 0;
- int index = 0;
- int history_no = 0;
- HIST_ENTRY *history = NULL;
- #if 0
- // readline呼び出し
- while (line = readline(prompt)) {
- lineSize = strlen(line);
- for (index = lineSize - 1; index >= 0; index--) {
- printf("%c", line[index]);
- }
- printf("\n");
- add_history(line);
- if (++history_no > MAX_HISTORY_NO) {
- history = remove_history(0);
- free(history);
- }
- // 入力文字列領域開放
- free(line);
- }
- printf("\n");
- clear_history();
- #endif
- line = readline(prompt);
- printf(" last input = [ %s ]\n", line);
- free(line);
- return EXIT_SUCCESS;
- }
复制代码- sgq@sgq-PC-MY28VCZEE:~$ dpkg -l | grep readline
- ii lib64readline-gplv2-dev 5.2-11 GNU readline and history libraries, development files (64-bit)
- ii lib64readline5 5.2-11 GNU readline and history libraries, run-time libraries (64-bit)
- ii libreadline5 5.2-11 GNU readline and history libraries, run-time libraries
- ii libreadline6 6.2-8 GNU readline and history libraries, run-time libraries
- ii libreadline6-dev 6.2-8 GNU readline and history libraries, development files
- ii readline-common 6.2-8 GNU readline and history libraries, common files
- sgq@sgq-PC-MY28VCZEE:~$
复制代码- sgq@sgq-PC-MY28VCZEE:~$ gcc readline.c -o readline
- /tmp/ccwKd71P.o: In function `main':
- readline.c:(.text+0x49): undefined reference to `readline'
- collect2: ld returned 1 exit status
- sgq@sgq-PC-MY28VCZEE:~$
复制代码 编译不通过。还缺什么么? |
|