ybu*_*yug 31 c macos readline editline
我正在编写关于构建自己的LISP的教程(http://www.buildyourownlisp.com/chapter4_interactive_prompt),出于某种原因,当我尝试编译时,我得到了这个:
REPL.c:4:10: fatal error: 'editline/readline.h' file not found
#include <editline/history.h>
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
我已经安装了osx开发人员工具,brew正在显示readline已安装,当我尝试brew install editline时它不知道该怎么做.
这是我的代码:
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <editline/readline.h>
4 #include <editline/history.h>
5
6 int main(int argc, char** argv) {
7
8 /* version/exit info */
9 puts("Edward Version 0.0.1");
10 puts("Press Ctrl+c to Exit\n");
11
12 /* endless loop for main REPL */
13 while (1) {
14 /* output prompt and read line */
15 char* input = readline("lispy> ");
16
17 /* put input in history */
18 add_history(input);
19
20 /* Echo input back */
21 printf("No you're a %s\n", input);
22
23 /* free input */
24 free(input);
25 }
26 return 0;
27 }
Run Code Online (Sandbox Code Playgroud)
这显然是非常基本的,但我真的想让这个项目滚动,所以我希望我能弄清楚这一点.这是我用来编译的:
cc -std=c99 -Wall REPL.c -ledit -o REPL
Run Code Online (Sandbox Code Playgroud)
Mar*_*n R 35
仅包括
#include <editline/readline.h>
Run Code Online (Sandbox Code Playgroud)
如果安装了命令行工具,它应该存在.该文件包含libedit的"readline包装器",包括历史记录功能.<editline/history.h>OS X上不存在包含文件.
我用这个修改测试了你的代码,它编译并运行没有问题.
使用OSX Yosemite.我删除了 #include<editline/history.h>
然后用 cc -std=c99 -Wall test.c -ledit -o test
现在工作正常
| 归档时间: |
|
| 查看次数: |
7559 次 |
| 最近记录: |