本文介绍了尝试使用已安装的开发人员工具进行编译时,在macOS上找不到editline/history.h和editline/readline.h.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在本教程上构建自己的LISP( http://www.buildyourownlisp.com/chapter4_interactive_prompt),由于某种原因,当我尝试进行编译时,我得到了:

I am working on this tutorial on building your own LISP (http://www.buildyourownlisp.com/chapter4_interactive_prompt) and for some reason when I try to compile I get this:

REPL.c:4:10: fatal error: 'editline/readline.h' file not found
#include <editline/history.h>
^
1 error generated.

我已经安装了macOS开发人员工具,并且brew显示安装了readline,并且当我尝试brew install editline时不知道该怎么办.

I have installed the macOS developer tools, and brew is showing readline is installed and it doesn't know what to do when I try 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 }

这显然是非常基本的,但是我真的很想让这个项目开始进行,所以我希望我能弄清楚这一点.这是我用来编译的:

It is obviously very basic, but I really want to get this project rolling so I'm hoping I can figure this out. This is what I'm using to compile:

cc -std=c99 -Wall REPL.c -ledit -o REPL

推荐答案

仅包含

#include <editline/readline.h>

,如果已安装命令行工具,则应存在.该文件包含libedit的"readline包装器",还包括历史记录功能.包含文件< editline/history.h> 在OS X上不存在.

which should exist if the command line tools are installed. This file contains the"readline wrapper" for libedit, including the history functions as well.An include file <editline/history.h> does not exist on OS X.

我对您的代码进行了修改,并进行了编译和运行,没有任何问题.

I tested your code with that modification, and it compiled and ran without problems.

这篇关于尝试使用已安装的开发人员工具进行编译时,在macOS上找不到editline/history.h和editline/readline.h.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 15:49