'readline/readline.h' file not found

CLinuxLibreadline

C Problem Overview


I have included:

#include "stdio.h"    
#include <readline/readline.h>
#include <readline/history.h>

and my compiler includes the flag

-lreadline

but I am still receiving the error message:

fatal error: 'readline/readline.h' file not found

I am trying to use the function, readline();

Defined in more detail here: http://linux.die.net/man/3/readline

C Solutions


Solution 1 - C

You reference a Linux distribution, so you need to install the readline development libraries

On Debian based platforms, like Ubuntu, you can run:

sudo apt-get install libreadline-dev 

and that should install the correct headers in the correct places,.

If you use a platform with yum, like SUSE, then the command should be:

yum install readline-devel

Solution 2 - C

This command helped me on linux mint when i had exact same problem

gcc filename.c -L/usr/include -lreadline -o filename

You could use alias if you compile it many times Forexample:

alias compilefilename='gcc filename.c -L/usr/include -lreadline -o filename'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiontimeshift117View Question on Stackoverflow
Solution 1 - CMikeView Answer on Stackoverflow
Solution 2 - Cλjk.jkView Answer on Stackoverflow