Skip to content

Check for libtinfo after libncurses #1322

wants to merge 1 commit into from

3 participants


@gentoo: This seems like a possible [unusual, or mis-] configuration of your system ncurses library?

From the ncurses INSTALL file:

When building the ncurses library, organize as two parts: the curses library (libncurses) and the low-level terminfo library (libtinfo). This is done to accommodate applications that use only the latter.

But I'd put it more alone the lines of:

Configure in a way such that -lncurses will be missing symbols unless you also -ltinfo.

Fish needs more than just libtinfo to (fully) function properly, as it's largely a curses-based shell.
What's properly needed, if configured this way, is both the tinfo and curses libs, not one or the other.

Rather than use the configuration option above, the typical configuration today is to symlink your installed ncurses headers and libraries as lib[n]curses[t][w], libtinfo[t][w], and/or libtic[t][w], as compatibility requires.
See here, for instance.

However, should be looking for libncursesw before libncurses.
I believe this had been added at one point, but it seems to possibly have been inadvertently reverted.

@zanchey @ridiculousfish Re: #1271, perhaps Gentoo should be a candidate distro for this option?

The user-friendly shell member
zanchey commented Mar 10, 2014

I'm also curious to the rationale behind this change; I couldn't find any easy way to understand what has changed in Gentoo.

As far as I can tell, fish doesn't actually use more than libtinfo. I'm not 100% certain, but I think the only curses functions required are setupterm, del_curterm, tparm, and tputs.

I'm not sure about libncursesw. I can't see that it has ever been checked for; I also can't see that there are wide-character versions of any of the above functions, so there would be little point in linking against it.


I'm not sure about libncursesw.

I had thought it made it in with an early PR of mine. Its not all that important; except if a default install of nucrses has been configured with --enable-widec then everything gets appended with a w. Most (all?) distros will just symlink/rename for this, so it would be unlikely to be of much consequence.

I think the only curses functions required are setupterm, del_curterm, tparm, and tputs.

I believe the WINCH functions are derived from nucrses as well? (There's a fallback SIGWINCH handler, but I'm not sure how that works exactly.)

As far as I can tell, fish doesn't actually use more than libtinfo.

In terms of 'which libraries resolve which symbol names,', I think you're right. My super-scientific rationale for

Fish needs more than just libtinfo to (fully) function properly

Is really just along the lines of:

  • I certainly can't seem to get it to build with only the tinfo library.
  • When you build ncurses, all the utils (tic infocmp etc) will only link libtinfo, but anything that actually does anything graphically also link libncurses.

Anyway, if this were merged, I think it should be in the form of: (with libtinfo in the last part), no?
AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])


ncurses has properly supported building a separate terminal info library for more than a decade, and Gentoo Linux added optional support for this configuration in 2013 (see A tracker bug ( was set up to aid in getting existing packages to support this entirely valid but apparently still novel configuration.

You are looking for a setupterm() in libncurses and libcurses, which is fine for most configurations, and fish doesn't use anything special in terms of line drawing or other advanced stuff that [n]curses support. With a split libncurses/libtinfo configuration, setupterm() is not available in libncurses, but in libtinfo, and fish runs fine when linked solely against libtinfo.

The correct check (with my patch) is therefore to first try libncurses, then libtinfo and then libcurses, which does this:

1) For systems without the split libncurses/libtinfo, this changes nothing.
2) For systems with that split configuration, the configure script will fail to find setupterm() in libncurses, but will succeed with libtinfo.
3) For systems without ncurses, it will try libcurses instead.
4) Failing 3), configure will fail.

I don't see what wide ncurses (libncursesw) has to do with this - it's a different issue altogether that isn't caused/exemplified/fixed by/with this patch.

The user-friendly shell member
zanchey commented Mar 19, 2014

OK, that's what I was trying to establish. (To quote: "ah, Gentoo".) I agree that ncursesw is a separate issue and I'll merge this shortly.

Really we should be using pkg-config for ncurses (which tells me that the right way to link on my system is with -lncurses -ltinfo), but supporting that fully across platforms which don't have pkg-config seems to be hard.

@zanchey zanchey added a commit that closed this pull request Mar 19, 2014
@jer-gentoo jer-gentoo Check for libtinfo after libncurses 5f11854
@zanchey zanchey closed this in 5f11854 Mar 19, 2014
@zanchey zanchey added this to the next-minor milestone Mar 19, 2014
@zanchey zanchey self-assigned this Mar 19, 2014
@ridiculousfish ridiculousfish added a commit that referenced this pull request Mar 26, 2014
@jer-gentoo jer-gentoo Check for libtinfo after libncurses 9709c70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.