3

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.

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
  • 1
    Where did you install `libedit` to? That is, where are those header files? – kaylum Apr 30 '17 at 07:07
  • In a folder containing the program's(above code snippet) file. Is it the right place i am working on windows10 environment. –  Apr 30 '17 at 07:08
  • In that case try: `#include "editline/readline.h"` and `#include "editline/history.h"`. That is, use double quotes instead of angle brackets. – kaylum Apr 30 '17 at 07:13
  • It did'nt work... –  Apr 30 '17 at 07:39

4 Answers4

3

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.

  • Does someone knows how to do the same process in FreeBSD? I installed the binary editline but don't know how to execute or modify the program. – Nicolás Gómez Nov 19 '20 at 15:30
1

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

Keval Malde
  • 33
  • 1
  • 9
0

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

marmeladze
  • 6,468
  • 3
  • 24
  • 45
0

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