Skip to content

build(cmake): fail loudly when the readline library is found but its headers are missing#483

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/readline-require-header
Jul 14, 2026
Merged

build(cmake): fail loudly when the readline library is found but its headers are missing#483
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/readline-require-header

Conversation

@got3nks

@got3nks got3nks commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Fixes the confusing Alpine build failure reported in #481:

error: 'rl_compentry_func_t' does not name a type
error: 'readline' was not declared in this scope
error: 'rl_line_buffer' was not declared in this scope
...

Root cause

cmake/FindReadline.cmake sets HAVE_LIBREADLINE from a check_function_exists(readline) that links readline / edit / editline. That succeeds not only with GNU readline but also with libedit (which exports a readline() compatibility symbol), or with a bare libreadline.so runtime and no -dev headers installed. The header probes, however, look only for <readline.h> / <readline/readline.h>.

So on a box with the library but not the matching development headers — Alpine with libedit-dev but no readline-dev is the common trigger — config.h ends up with HAVE_LIBREADLINE but no header macro. src/ExternalConnector.cpp gates its rl_* block on HAVE_LIBREADLINE alone while including the header under HAVE_READLINE_READLINE_H / HAVE_READLINE_H, so the rl_* symbols are used undeclared and the build dies deep in compilation.

Fix

Require a usable header, not just the library. When the library is found but neither header is, stop at configure time with a message naming the missing package, instead of a confusing mid-build error:

The readline library was found but its development headers were not
(neither <readline/readline.h> nor <readline.h>). Install the readline
development package and re-run cmake -- e.g. Alpine: 'apk add readline-dev';
Debian/Ubuntu: 'apt install libreadline-dev'; Fedora: 'dnf install readline-devel';
macOS (Homebrew): 'brew install readline'.

Validation

  • Alpine repro (libedit-dev, no readline-dev): configure now stops with the message above; after apk add readline-devHAVE_LIBREADLINE=1, header found, Configuring done.
  • macOS (readline header present): unaffected — no fatal, amulecmd builds.

Refs #481

…headers are missing

FindReadline set HAVE_LIBREADLINE from a check_function_exists(readline)
that a bare runtime library -- or libedit's readline() compatibility
symbol -- also satisfies, while the header probes look only for
<readline.h> / <readline/readline.h>. On a box with the library but no
development headers (e.g. Alpine with libedit-dev but no readline-dev),
config.h carried HAVE_LIBREADLINE with no header macro, and
ExternalConnector.cpp -- which gates its rl_* block on HAVE_LIBREADLINE
alone -- failed deep in the build with "rl_compentry_func_t does not name
a type" and friends (amule-project#481).

Require a usable header too: when the library is found but neither header
is, stop at configure time with a message naming the missing package
(Alpine readline-dev / Debian libreadline-dev / Fedora readline-devel /
Homebrew readline) instead of a confusing mid-build error.
@got3nks got3nks merged commit 42cbe88 into amule-org:master Jul 14, 2026
12 checks passed
@got3nks got3nks deleted the fix/readline-require-header branch July 14, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant