if libncurses is configured to use the separate libtinfo library, half of the symbols go into libtinfo and then libncurses is linked against it
so AC_CHECK_LIB is unadequate for checking if libncurses is present or not
pkg-config file ncurses.pc should be used instead to get correct Libs: and Libs.private: contents
not doing so results in compile errors like:
libtool: link: x86_64-pc-linux-gnu-gcc -Wall -pipe -march=btver1 -mtune=btver1 -Wl,-O1 -o .libs/lame lame_main.o main.o brhist.o console.o get_audio.o lametime.o parse.o timestatus.o -Wl,--as-needed ../libmp3lame/.libs/libmp3lame.so -lncurses /usr/lib64/libsndfile.so -lFLAC -lvorbisenc -lvorbis -logg -lm
libtool: link: x86_64-pc-linux-gnu-gcc -Wall -pipe -march=btver1 -mtune=btver1 -Wl,-O1 -o .libs/mp3rtp mp3rtp.o rtp.o main.o brhist.o console.o get_audio.o lametime.o parse.o timestatus.o -Wl,--as-needed ../libmp3lame/.libs/libmp3lame.so -lncurses /usr/lib64/libsndfile.so -lFLAC -lvorbisenc -lvorbis -logg -lm
console.o: In function `get_termcap_string':
console.c:(.text+0xe3): undefined reference to `tgetstr'
console.o: In function `get_termcap_number':
console.c:(.text+0x14a): undefined reference to `tgetnum'
console.o: In function `apply_termcap_settings':
console.c:(.text+0x1a9): undefined reference to `tgetent'
collect2: ld returned 1 exit status
console.o: In function `get_termcap_string':
console.c:(.text+0xe3): undefined reference to `tgetstr'
console.o: In function `get_termcap_number':
console.c:(.text+0x14a): undefined reference to `tgetnum'
console.o: In function `apply_termcap_settings':
console.c:(.text+0x1a9): undefined reference to `tgetent'
collect2: ld returned 1 exit status
as reported downstream here:
https://bugs.gentoo.org/show_bug.cgi?id=454322
the attached patch fixes things
just for the record:
- building separate libtinfo is optional in Gentoo Linux
- Debian has it always built as separate
don't know about others
In fact, if libtinfo is built, then it doesn't link against libncurses at all, so adding AC_CHECK_LIB, as last one, for tinfo, might just work too
but I still prefer pkg-config
$ objdump -p /usr/bin/lame |grep NEEDED
NEEDED libmp3lame.so.0
NEEDED libtinfo.so.5
NEEDED libsndfile.so.1
NEEDED libm.so.6
NEEDED libc.so.6
New patch, replaces the pkg-config version
configure.in was checking initscr() function from the termcap libraries, whereas iniscr() is not used anywhere in the lame code, so changing it to the used function tgetent() seemed appropiate
then since as explained earlier, libtinfo can be built out from libncurses source tree, which moves the tgetent() function from -lncurses to -ltinfo
so I've simply added new AC_CHECK_LIB there, and it works nicely