Skip to content

Instantly share code, notes, and snippets.

@bmink
Last active March 19, 2025 02:04
Show Gist options
  • Save bmink/a7848eaa41a6d55fc7bc0b2db656f9a0 to your computer and use it in GitHub Desktop.
Save bmink/a7848eaa41a6d55fc7bc0b2db656f9a0 to your computer and use it in GitHub Desktop.
readline on MacOS X
OS X does not come with readline, rather, it comes with libedit which is touted as being a readline-compatible replacement.
This may be true for basic usage, but advanced usage will run into compabitily problems.
For example, trying to build https://github.com/ulfalizer/readline-and-ncurses on Mac will complain about not finding some variables exported by readline.
Solution: brew install readline
Brew will not override OS X's readline (which is really libedit). Its output helpfully states:
--------------------
readline is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides BSD libedit.
For compilers to find readline you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/readline/lib"
export CPPFLAGS="-I/opt/homebrew/opt/readline/include"
--------------------
Adding the above compile and linker flags into the Makefile solved the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment