Subject: libncurses5-dev: static linking with -lncurses is broken

From: Sven Joachim <[email-masked]>
Date: Sat, 08 Oct 2011 16:14:43 +0200

Package: libncurses5-dev
Version: 5.9-2
Severity: serious
X-Debbugs-CC: Matthias Klose <[email-masked]>

Static linking with -lncurses fails if you need symbols from libtinfo:

,----
| $ cat foo.c
| #include <term.h>
| #include <stdlib.h>
| 
| int main(void)
| {
|   return tgetent(NULL, "");
| }
| $ LANG=C gcc foo.c -lncurses -static
| /tmp/ccRe0RW2.o: In function `main':
| foo.c:(.text+0x19): undefined reference to `tgetent'
| collect2: ld returned 1 exit status
`----

This makes zsh and possibly a few other packages FTBFS.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.1.0-rc9-nouveau (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libncurses5-dev depends on:
ii  libc6-dev [libc-dev]  2.13-21
ii  libncurses5           5.9-2
ii  libtinfo-dev          5.9-2
ii  ncurses-bin           5.9-2

libncurses5-dev recommends no packages.

Versions of packages libncurses5-dev suggests:
ii  ncurses-doc  5.9-2

-- no debconf information

---

From: Sven Joachim <[email-masked]>
Date: Sat, 08 Oct 2011 19:12:00 +0200

> This makes zsh and possibly a few other packages FTBFS.

So maybe we need to "append" each libtinfo.a to libncurses{,w}.a, like
this:

ar xo libtinfo.a && ar sr libncurses.a *.o && rm -f *.o

Any less ugly ideas?

Cheers,
       Sven

---

From: Thomas Dickey <[email-masked]>
Date: Sat, 8 Oct 2011 13:56:29 -0400 (EDT)

> ar xo libtinfo.a && ar sr libncurses.a *.o && rm -f *.o

If zsh used pkg-config, it could use today's update (ncurses patch)

 	pkg-config --static --libs ncurses

That's one path forward...

But most of your FTBFS's will be only looking for "-lncurses", not
supposing that tgetent would be in another library.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

---

From: Matthias Klose <[email-masked]>
Date: Sun, 09 Oct 2011 10:23:36 +0200

> supposing that tgetent would be in another library.

I like the idea of fixing pkg-config, and making the "few" packages to use it.
Do you have an idea how many packages are affected?

---

From: Thomas Dickey <[email-masked]>
Date: Sun, 9 Oct 2011 06:35:19 -0400 (EDT)

> On 10/08/2011 07:56 PM, Thomas Dickey wrote:
...
> Do you have an idea how many packages are affected?

not I (remember I'm the upstream, and can only guess)

---

From: Sven Joachim <[email-masked]>
Date: Sun, 09 Oct 2011 18:00:46 +0200

> Do you have an idea how many packages are affected?

Of the -static packages in Debian, only bash it seems.  Version 4.1-3
will FTBFS when I make the intended changes to fix bug #644426, but
4.2-1~exp1 does not link to ncurses so should not be affected (didn't
test it because of #641350).

But maybe we should also think about our users who will have a hard time
linking anything statically with ncurses.

Cheers,
       Sven

---

From: Julien Cristau <[email-masked]>
Date: Mon, 10 Oct 2011 21:39:09 +0200

> linking anything statically with ncurses.
Are there really that many people doing that?  And who can't replace
"-lncurses" with "pkg-config --static --libs ncurses"?

Cheers,
Julien

---

From: Sven Joachim <[email-masked]>
Date: Mon, 10 Oct 2011 22:33:16 +0200

On 2011-10-10 21:39 +0200, Julien Cristau wrote:

> Are there really that many people doing that?

Apparently not, since I could not find many complaints about Fedora's
ncurses-static package which have the same problem as we do.

>  And who can't replace

People who are running other people's `configure' scripts may have some
trouble doing that (not everybody knows autoconf/automake).  And
pkg-config support in ncurses is relatively new, it was added shortly
after the 5.7 release.

But probably we can live with that, it seems.

Cheers,
       Sven

---

From: Sven Joachim <[email-masked]>
Date: Wed, 12 Oct 2011 18:42:33 +0200

clone 644728 -1
reassign -1 zsh 4.3.12-1
retitle -1 zsh: FTBFS: configure: error: "No terminal handling library was found on your system."
clone 644728 -2
reassign -2 bash 4.1-3
retitle -2 bash: FTBFS with libncurses5-dev 5.9-3
severity -2 important
tags -2 wheezy sid
retitle 644728 libncurses5-dev: static linking with -lncurses requires -ltinfo as well
severity 644728 normal
thanks

> | collect2: ld returned 1 exit status

The general opinion seems to be that this is acceptable, and that people
wishing statically linking with ncurses need to specify -ltinfo
themselves, e.g. by using "pkg-config --static --libs ncurses" (only
possible in wheezy and later, though).

> This makes zsh and possibly a few other packages FTBFS.

The only other affected package I know of is bash which does not FTBFS
right now, but will with libncurses5-dev 5.9-3 due to the changes for
#644426.  I will followup on the cloned bugs individually once I have
their numbers.

Cheers,
       Sven