当尝试使用已安装的开发人员工具进行编译时,editline/history.h 和 editline/readline.h 在 macOS 上未找到/工作

2024-04-12

我正在编写有关构建您自己的 LISP 的教程(http://www.buildyourownlisp.com/chapter4_interactive_prompt 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.

我已经安装了 macOS 开发人员工具,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 } 

这显然是非常基本的,但我真的想让这个项目滚动起来,所以我希望我能解决这个问题。这就是我用来编译的:

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

仅包含

#include <editline/readline.h>

如果安装了命令行工具,它应该存在。该文件包含 libedit 的“readline 包装器”,还包括历史功能。 包含文件<editline/history.h>OS X 上不存在。

我用这个修改测试了你的代码,它编译并运行没有问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当尝试使用已安装的开发人员工具进行编译时,editline/history.h 和 editline/readline.h 在 macOS 上未找到/工作 的相关文章

随机推荐