Skip to content

readline: fix dependency in pkgconfig file#3303

Open
jagot wants to merge 2 commits into
spack:developfrom
jagot:fix-readline
Open

readline: fix dependency in pkgconfig file#3303
jagot wants to merge 2 commits into
spack:developfrom
jagot:fix-readline

Conversation

@jagot

@jagot jagot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Ensure correct dependency on ncurses (and not the ancient termcap) is listed in the generated pkgconfig for readline. This is important for programs linking to readline, who will look for a (probably non-existent) termcap library, when readline was in fact built against ncurses.

@haampie

haampie commented Feb 9, 2026

Copy link
Copy Markdown
Member

Does this work? I see

checking for tgetent in -ltermcap... yes
checking which library has the termcap functions... using libtermcap
checking for ncurses/termcap.h... yes

@jagot

jagot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, I was not being clear. readline builds fine, the issue is that the generated readline.pc contains a reference to termcap, although it was not actually used for building readline.

MWE

test-readline.c:

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

int main(int argc, char* argv[]) {
  char* line = readline("input something> ");
  printf("Read input: %s", line);

  return 0;
}

Makefile:

all: test-readline

CFLAGS=`pkg-config --cflags readline`
LDFLAGS=`pkg-config --libs readline`

test-readline: test-readline.o
	gcc -o $@ $< $(LDFLAGS)

%.o: %.c
	gcc -o $@ -c $^ $(CFLAGS)

.PHONY: clean
clean:
	rm -f *.o test-readline

Without this PR

Tested using v8.2 because v8.3 was built with my fix, and I don't want to nuke my environment, but the results are the same.

$ cat cat $(pkg-config --path readline)
prefix=/opt/homebrew/Cellar/spack/1.1.0/opt/spack/darwin-m3/readline-8.2-4ir47ylbi7sdzlba2y2ntqm7ffkq3lto
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Readline
Description: Gnu Readline library for command line editing
URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html
Version: 8.2
Requires.private: termcap
Libs: -L${libdir} -lreadline
Cflags: -I${includedir}

$ make && ./test-readline
gcc -o test-readline.o -c test-readline.c `pkg-config --cflags readline`
Package termcap was not found in the pkg-config search path.
Perhaps you should add the directory containing `termcap.pc'
to the PKG_CONFIG_PATH environment variable
Package 'termcap', required by 'readline', not found
gcc -o test-readline test-readline.o `pkg-config --libs readline`
Package termcap was not found in the pkg-config search path.
Perhaps you should add the directory containing `termcap.pc'
to the PKG_CONFIG_PATH environment variable
Package 'termcap', required by 'readline', not found
Undefined symbols for architecture arm64:
  "_readline", referenced from:
      _main in test-readline.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test-readline] Error 1

With this PR

cat $(pkg-config --path readline)
prefix=/opt/homebrew/Cellar/spack/1.1.0/opt/spack/darwin-m3/readline-8.3-rxoyy4phdadh5isghpfz3orodumnbaqa
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Readline
Description: Gnu Readline library for command line editing
URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html
Version: 8.3
Requires.private: ncurses
Libs: -L${libdir} -lreadline
Cflags: -I${includedir}

$ make && ./test-readline
gcc -o test-readline.o -c test-readline.c `pkg-config --cflags readline`
gcc -o test-readline test-readline.o `pkg-config --libs readline`
input something> hello there
Read input: hello there

@jagot

jagot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Friendly bump :)

@jagot jagot force-pushed the fix-readline branch 3 times, most recently from b696cbb to f605ad2 Compare June 23, 2026 14:28
@bernhardkaindl bernhardkaindl enabled auto-merge (squash) June 27, 2026 15:37
@bernhardkaindl bernhardkaindl disabled auto-merge June 27, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants