Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

editline

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.


2 Answers

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.

like image 86
nigomeza Avatar answered Oct 30 '25 03:10

nigomeza


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

like image 29
Keval Malde Avatar answered Oct 30 '25 03:10

Keval Malde