fatal error: editline/readline.h: No such file or directory compilation terminated

5.6k Views Asked by At

Fatal Error

I am working on makeyourownlisp,where in editline/readline.h and editline/history.h have to be added to the program. Following is the code snippet

#include<stdio.h>
#include<stdlib.h>

#include<editline/readline.h>
#include<editline/history.h>

static char  input[2048];

int main(int argc, char** argv)
{
    printf("CLISP version 1.02\n");
    printf("Ctrl + c to exit\n");

    while(1)
    {
        char * input = readline(">>> \n");
        add_history(input);

        printf("%s", input);
        free(input);
    }
}

I have already installed libedit-20170329-3.1(containing the above mentioned header files) but how to use the files and get the code rolling is something I need help about.

4

There are 4 best solutions below

0
marmeladze On

An answer from future.

I am also working on same tutorial. And I also get stuck at that point. Then removing #include<editline/history.h> solved my issue.

Thanks to that thread https://github.com/fabianishere/brainfuck/issues/57

P.S. I am using Archlinux

1
Nicolás Gómez On

On Debian Buster 10, I had to install the package with:

sudo apt install libeditline-dev 

Instead of:

#include <editline/readline.h>
#include <editline/history.h>

I just included:

#include <editline.h>

ran the program with -leditline flag and worked perfectly. Note that I was executing the portable program for both Windows and UNIX systems. Following the tutorial, that piece of my code would look like:

// otherwise include the editline headers
#else
#include <editline.h>
#endif

Hope that helped. Awesome tutorial btw.

0
Keval Malde On

I faced this issue in the ubuntu 18.04 version, installing the following packages worked for me

sudo apt install libeditline-dev 
sudo apt-get install libedit-dev

I refer to the following thread Readline-Issue

0
Shaurya On

to install editline header file use,

sudo apt-get install libedit-dev

or for fedora use,

su -c "yum install libedit-dev*"

then proceed to add the header files like this

#include <stdio.h>
#include <stdlib.h>
#include <editline/readline.h>
#include <editline/history.h>

use them as the Header files and then use the History and readline command as usual as given in the tutorial.

Then when compiling use (assuming your file name is "prompt.c" and the output compiled file is "PromptOutput"

gcc prompt.c -ledit -o PromptOutput

instead of

gcc prompt.c -o PromptOutput

this is because we haven't previously linked the program to "editline".

I am using Ubuntu 20.X.

for Arch, use

histedit.h

I hope that clears the query