editline / history.h和editline / readline.h没有发现/试图与已经安装开发工具编译时OSX工作 [英] editline/history.h and editline/readline.h not found/working on OSX when trying to compile with developer tools installed already

查看:1206
本文介绍了editline / history.h和editline / readline.h没有发现/试图与已经安装开发工具编译时OSX工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的这个教程对构建自己的LISP(<一个href=\"http://www.buildyourownlisp.com/chapter4_interactive_prompt\">http://www.buildyourownlisp.com/chapter4_interactive_prompt)出于某种原因,当我尝试编译我得到这样的:

  REPL.c:4:10:致命错误:'editline / readline.h'文件未找到
#包括LT&; editline / history.h&GT;
^
产生1个错误。

我已经安装了OSX开发工具和BREW是显示已安装的readline和它不知道,当我尝试酿造安装editline做什么。

这是我的code:

  1的#include&LT;&stdio.h中GT;
  2#包括LT&;&stdlib.h中GT;
  3#包括LT&; editline / readline.h&GT;
  4#包括LT&; editline / history.h&GT;
  五
  6 INT主(INT ARGC,字符** argv的){
  7
  8 / *版本/出境信息* /
  9看跌期权(爱德华版本0.0.1);
 10看跌期权(preSS Ctrl + C可退出\\ n);
 11
 12 / *无限循环主REPL * /
 13,而(1){
 14 / *输出提示和读行* /
 15字符*输入=的ReadLine(lispy&GT;);
 16
 在历史上17 / *把输入* /
 18 add_history(输入);
 19
 20 / *回声回输入* /
 21的printf(不,你是一个%S \\ n,输入);
 22
 23 / *自由输入* /
 24免费(输入);
 25}
 26返回0;
 27}

这显然是非常基本的,但我真的想获得这个项目滚动所以我希望我能想出解决办法。这是我使用的编译内容:

  CC -std = C99 -Wall REPL.c -ledit -o REPL


解决方案

只包括

 的#include&LT; editline / readline.h&GT;

如果安装了命令行工具,应该存在。此文件包含
readline的包装为libedit,包括历史记录功能,以及。
包含文件&LT; editline / history.h方式&gt; 在OS X上不存在

我测试了code与修改,并编译和运行没有问题。

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.

I have installed the osx developer tools and brew is showing readline is installed and it doesnt know what to do when i try brew install editline.

This is my code:

  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 only

#include <editline/readline.h>

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.

这篇关于editline / history.h和editline / readline.h没有发现/试图与已经安装开发工具编译时OSX工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆