Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 454736

Summary: x11-terms/xterm-285 with sys-libs/ncurses[tinfo] - resize.c:(.text.startup+0x127): undefined reference to `tgetent'
Product: Gentoo Linux Reporter: Jan Paesmans <jan.paesmans>
Component: Current packagesAssignee: Thomas Dickey <dickey>
Severity: normal CC: jlec, travisghansen, x11
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 457530    

Description Jan Paesmans 2013-01-30 20:46:33 UTC
After upgrading ncurses, xterm-285 fails to link with ncurses. Same problem happens when enabling ncurses use flag with openrc. During linking of xterm executable, no library ncurses is seen. In the config.log, I saw that a testlink of ncurses failed. This is due to the libraries for ncurses being wrong, pkg-config --libs ncurses gives -lncurses -ltinfo. Whoever in the gcc command line, only -lncurses is given. config.log attached after emerge --info

Reproducible: Always

Steps to Reproduce:
1. update sys-libs/ncurses
2. re-emerge xterm
Actual Results:  
/bin/sh ./ x86_64-pc-linux-gnu-gcc -march=amdfam10 -O3 -pipe -fomit-frame-pointer -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wdeclaration-after-statement -Wextra -Wno-unknown-pragmas -Wswitch-enum -Wl,-O1 -Wl,--as-needed  -o resize resize.o xstrings.o -lfontconfig -lXft -lXaw3d -lXmu -lXt -lX11 -lXext -lXpm -lSM -lICE -lXt -lX11 -lutempter
testing if -lfontconfig is needed
testing if -lXft is needed
testing if -lXaw3d is needed
testing if -lXmu is needed
testing if -lXt is needed
testing if -lX11 is needed
testing if -lXext is needed
testing if -lXpm is needed
testing if -lSM is needed
testing if -lICE is needed
testing if -lXt is needed
testing if -lX11 is needed
testing if -lutempter is needed
resize.o: In function `main':
resize.c:(.text.startup+0x127): undefined reference to `tgetent'
collect2: ld returned 1 exit status
make: *** [resize] Error 1
make: *** Waiting for unfinished jobs....
 * ERROR: x11-terms/xterm-285 failed (compile phase):
 *   emake failed

Expected Results:  
xterm successfully emerged

emerge --info:
Portage (default/linux/amd64/10.0/desktop, gcc-4.6.3, glibc-2.15-r3, 3.7.4 x86_64)
                         System Settings
System uname: Linux-3.7.4-x86_64-AMD_Phenom-tm-_II_X6_1090T_Processor-with-gentoo-2.1
Timestamp of tree: Sun, 27 Jan 2013 20:15:01 +0000
ld GNU ld (GNU Binutils) 2.22
distcc 3.1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.3-r2, 3.1.5, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.6 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo
ACCEPT_LICENSE="* -@EULA AdobeFlash-10.3 Intel-SDP Oracle-BCLA-JavaSE"
CFLAGS="-march=amdfam10 -O3 -pipe -fomit-frame-pointer"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="${EPREFIX}/etc/gconf /etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=amdfam10 -O3 -pipe -fomit-frame-pointer"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS=" rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync:// rsync://"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif gpm gtk iconv ipv6 jpeg lcms ldap libnotify mad mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds qt3support qt4 readline sdl session spell sse sse2 ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vorbis wxwidgets x264 xcb xml xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="adc65 agfa_cl20 aox ax203 barbie canon casio_qv clicksmart310 digigr8 digita dimagev dimera3500 directory enigma13 fuji gsmart300 hp215 iclick jamcam jd11 jl2005a jl2005c kodak_dc120 kodak_dc210 kodak_dc240 kodak_dc3200 kodak_ez200 konica konica_qm150 largan lg_gsm mars mustek panasonic_coolshot panasonic_dc1000 panasonic_dc1580 panasonic_l859 pccam300 pccam600 polaroid_pdc320 polaroid_pdc640 polaroid_pdc700 ptp2 ricoh ricoh_g3 samsung sierra sipix_blink sipix_blink2 sipix_web2 smal sonix sony_dscf1 sony_dscf55 soundvision spca50x sq905 st2205 stv0674 stv0680 sx330z template topfield toshiba_pdrm11 tp6801" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="nlpsolver pdfimport presenter-console presenter-minimizer scripting-beanshell scripting-javascript wiki-publisher" LINGUAS="en nl" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

                        Package Settings

x11-terms/xterm-285 was built with the following:
USE="Xaw3d (multilib) truetype unicode -toolbar"

relevant config.log section:

configure:5607: x86_64-pc-linux-gnu-gcc -o conftest -march=amdfam10 -O3 -pipe -fomit-frame-pointer  -D_GNU_SOURCE -Wl,-O1 -Wl,--as-needed conftest.c -lncurses  >&5
/var/tmp/portage/x11-terms/xterm-285/temp/ccWWxK2x.o: In function `main':
conftest.c:(.text.startup+0x16): undefined reference to `tgetent'
collect2: ld returned 1 exit status
configure:5610: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 5592 "configure"
#include "confdefs.h"

/* terminfo implementations ignore the buffer argument, making it useless for
 * the xterm application, which uses this information to make a new TERMCAP
 * environment variable.
int main()
        char buffer[1024];
        buffer[0] = 0;
        tgetent(buffer, "vt100");
        return (0); }
no, there is no termcap/tgetent in ncurses
configure:5607: x86_64-pc-linux-gnu-gcc -o conftest -march=amdfam10 -O3 -pipe -fomit-frame-pointer  -D_GNU_SOURCE -Wl,-O1 -Wl,--as-needed conftest.c -lcurses  >&5
/var/tmp/portage/x11-terms/xterm-285/temp/cc1fi6OK.o: In function `main':
conftest.c:(.text.startup+0x16): undefined reference to `tgetent'
collect2: ld returned 1 exit status
configure:5610: $? = 1
configure: program exited with status 1
configure: failed program was:
#line 5592 "configure"
Comment 1 Travis Hansen 2013-01-31 07:22:46 UTC
This little bug is causing me grief with all kinds of packages.  I have issues building:


All of them build fine if I set:

LDFLAGS=" -L/lib -lncurses" emerge foo
Comment 2 Chí-Thanh Christopher Nguyễn gentoo-dev 2013-01-31 10:30:09 UTC
Builds fine here.
# ncurses5-config --libs
-L/usr/lib64 -lncurses
Comment 3 Jan Paesmans 2013-01-31 19:50:12 UTC
This is the piece of c-code that is used by autoconf:

int main()
        char buffer[1024];
        buffer[0] = 0;
        tgetent(buffer, "vt100");
        return (0);

Autoconf tries to compile with the following cmd-line:

x86_64-pc-linux-gnu-gcc -o conftest -march=amdfam10 -O3 -pipe -fomit-frame-pointer  -D_GNU_SOURCE -Wl,-O1 -Wl,--as-needed conftest.c -lcurses

Resulting in the following error:

In function `main':
conftest.c:(.text.startup+0x16): undefined reference to `tgetent'
collect2: ld returned 1 exit status

To successfully compile I need to add -ltinfo. This is where the symbol 'tgetent' is located.

Autoconf script doesn't use ncurses5-config and running ncurses5-config gives the following:

ncurses5-config --libs
-L/usr/lib64 -lncurses -ltinfo

This means that adding -ltinfo is needed
Comment 4 Jan Paesmans 2013-01-31 20:07:05 UTC
Using the output of ncurses5-config and setting

LDFLAGS="-L/usr/lib64 -lncurses -ltinfo" emerge -v xterm 

works. A variant to what Travis Hansen suggests.
Comment 5 Travis Hansen 2013-01-31 20:12:00 UTC
I think there's a deeper issue here as well.  Look at the differnces in filesizes:

15z ~ # ls -l /lib64/ 
-rwxr-xr-x 1 root root 142816 Jan 17 01:29 /lib64/
15z ~ # ls -l /usr/lib64/ 
-rwxr-xr-x 1 root root 529 Jan 17 01:29 /usr/lib64/

And is it standard procedure to have libs with the same name in different dirs?
Comment 6 Chí-Thanh Christopher Nguyễn gentoo-dev 2013-01-31 20:24:23 UTC
CC:'ing ncurses maintainers, maybe they can suggest what is the correct way to address this issue.
Comment 7 SpanKY gentoo-dev 2013-02-03 05:24:12 UTC
(In reply to comment #6)

use ncurses' .pc file rather than -lncurses to link.  the ncurses ebuild isn't broken here.
Comment 8 Jan Paesmans 2013-02-03 20:07:48 UTC
As indicated, there is something wrong with the configure script.

autoconf tries to check for termcap/curses/ncurses libraries. It does this by testing for each by trying to link the conftest.c file as mentioned after the emerge --info section. This is wrong, autoconf's check for termcap/curses/ncurses is wrong. If it wants to see if libncurses can be used by compiling and linking a test code, that at least for libncurses it must use the proper libraries. This can be done by using pkg-config.

If someone tells me that this is not a problem, again try compiling and linking the example code given with the ncurses5.9-r2, than you'll see that the test as preformed by autoconf is _wrong_!
Comment 9 Jan Paesmans 2013-02-04 21:04:44 UTC
Linking rc from openrc suffers from the same problem. Linking with the ncurses5.9-r2 fails. In mk/, if you want to link with this ncurses5.9-r2, you need -lncurses -ltinfo, not just -lncurses.
This is not automake, so in the future, it might be easier to use ncurses pkg-config there.
Comment 10 SpanKY gentoo-dev 2013-02-05 23:56:01 UTC
(In reply to comment #9)

file new bugs for new issues.  this bug is just for xterm.
Comment 11 Travis Hansen 2013-02-06 00:19:30 UTC
I think it's time a tracker bug be opened to deal with the packages affected by this issue.
Comment 12 Justin Lecher gentoo-dev 2013-02-14 13:42:47 UTC
+  14 Feb 2013; Justin Lecher <> xterm-285.ebuild,
+  xterm-288.ebuild, metadata.xml:
+  Add Workaround for ncurses[tinfo], #454736; correct HOMEPAGE; improve usage
+  of EAPI >=4; add missing die
Comment 13 Justin Lecher gentoo-dev 2013-02-14 13:44:44 UTC
Thomas, could you please make the buildsystem use pkg-config to detect ncurses libs? 
And while you are at it, I saw you are still using the long deprecated instead of .ac naming. This will become a problem with next automake release. A simple rename should do it.
Comment 14 Travis Hansen 2013-02-14 16:32:59 UTC
Do we have a tracker bug yet for all the packages that have this issue?
Comment 15 Chí-Thanh Christopher Nguyễn gentoo-dev 2013-02-14 16:34:31 UTC
(In reply to comment #14)
Yes, bug 457530 which is already blocked by this bug.