FS#56000 - [ncurses] build failures with weechat due to new termlib=tinfo

Attached to Project: Arch Linux
Opened by Earnestly (Earnest) - Sunday, 15 October 2017, 16:22 GMT
Last edited by Bartłomiej Piotrowski (Barthalion) - Sunday, 10 December 2017, 22:09 GMT
Task Type Bug Report
Category Packages: Testing
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Since the addition of --with-termlib=tinfo the weechat build is now failing with the following error:

[ 98%] Linking CXX static library libweechat_unit_tests.a
/usr/bin/ld: libweechat_gui_curses.a(gui-curses-window.o): undefined reference to symbol 'acs_map'
/usr/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/gui/curses/CMakeFiles/weechat.dir/build.make:106: src/gui/curses/weechat] Error 1
make[1]: *** [CMakeFiles/Makefile2:2186: src/gui/curses/CMakeFiles/weechat.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 98%] Built target weechat_unit_tests
make: *** [Makefile:163: all] Error 2

This is because the command-line is not including -ltinfo as seen here:

/usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Wextra -Werror-implicit-function-declaration -O2 -g -DNDEBUG -L/usr/lib -L/usr/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -rdynamic CMakeFiles/weechat.dir/main.o -o weechat ../libweechat_gui_common.a ../../plugins/libweechat_plugins.a ../../core/libweechat_core.a ../libweechat_gui_common.a libweechat_gui_curses.a -lgcrypt -lgpg-e

What was the rational for --with-termlib=tinfo and what do you expect upstream to do here?
This task depends upon

Closed by  Bartłomiej Piotrowski (Barthalion)
Sunday, 10 December 2017, 22:09 GMT
Reason for closing:  Fixed
Comment by Earnestly (Earnest) - Sunday, 15 October 2017, 16:27 GMT
Sorry, for some reason entire command-line didn't copy, the full one is here:

/usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Wextra -Werror-implicit-function-declaration -O2 -g -DNDEBUG -L/usr/lib -L/usr/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -rdynamic CMakeFiles/weechat.dir/main.o -o weechat ../libweechat_gui_common.a ../../plugins/libweechat_plugins.a ../../core/libweechat_core.a ../libweechat_gui_common.a libweechat_gui_curses.a -lgcrypt -lgpg-error -lgnutls -ldl -lncursesw -lpthread -lm -lcurl ../libweechat_gui_common.a ../../plugins/libweechat_plugins.a ../../core/libweechat_core.a ../libweechat_gui_common.a

Comment by Earnestly (Earnest) - Sunday, 15 October 2017, 19:39 GMT
I've written up a very basic patch to try and incorporate pkg-config into their
cmake system, and although it works it's not done very nicely since it would
likely be preferable to completely reimplement FindNcurses.cmake in terms of
PkgConfig but I'm not very familiar with cmake. I've mentioned this in
#weechat but haven't had any replies yet.

So here is my half-attempt which can probably be built on or improved, but the
basic idea is there and it results in a linking weechat even if we end up with
two -lncursew flags.


diff --git a/cmake/FindNcurses.cmake b/cmake/FindNcurses.cmake
index cc2f17126..1e5057cc6 100644
--- a/cmake/FindNcurses.cmake
+++ b/cmake/FindNcurses.cmake
@@ -51,6 +51,12 @@ if(NCURSES_INCLUDE_PATH AND NCURSES_LIBRARY)
set(NCURSES_FOUND TRUE)
endif()

+find_package(PkgConfig QUIET)
+
+If(PKG_CONFIG_FOUND)
+ pkg_search_module(NCURSES ncurses)
+endif()
+
mark_as_advanced(
NCURSES_INCLUDE_PATH
NCURSES_LIBRARY
diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt
index cdb8f9d78..5c3d3e2e3 100644
--- a/src/gui/curses/CMakeLists.txt
+++ b/src/gui/curses/CMakeLists.txt
@@ -47,6 +47,10 @@ if(NCURSES_FOUND)
endif()
endif()
list(APPEND EXTRA_LIBS ${NCURSES_LIBRARY})
+
+ if(NCURSES_FOUND)
+ list(APPEND EXTRA_LIBS ${NCURSES_LIBRARIES})
+ endif()
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
Comment by Earnestly (Earnest) - Monday, 16 October 2017, 12:39 GMT
For reference, this was apparently reported to weechat in 2014: https://savannah.nongnu.org/bugs/?41245
Comment by Andreas (misc) - Monday, 16 October 2017, 16:05 GMT
Similar build error now occurs for zsh (5.4.2 and git):

checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking ncursesw/ncurses.h usability... no
checking ncursesw/ncurses.h presence... no
checking for ncursesw/ncurses.h... no
checking ncurses/ncurses.h usability... no
checking ncurses/ncurses.h presence... no
checking for ncurses/ncurses.h... no
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking dl.h usability... no
checking dl.h presence... no
checking for dl.h... no
checking for conflicts in sys/time.h and sys/select.h... no
checking TIOCGWINSZ in termios.h... no
checking TIOCGWINSZ in sys/ioctl.h... yes
checking for streams headers including struct winsize... no
checking for printf in -lc... yes
checking for pow in -lm... yes
checking for clock_gettime in -lrt... yes
checking for library containing tigetstr... no
checking if _XOPEN_SOURCE_EXTENDED should not be defined... no
checking for library containing tigetflag... no
checking for library containing tgetent... no
configure: error: in `/tmp/makepkg/zsh/src/zsh-5.4.2':
configure: error: "No terminal handling library was found on your system.
This is probably a library called 'curses' or 'ncurses'. You may
need to install a package called 'curses-devel' or 'ncurses-devel' on your
system."
Comment by Earnestly (Earnest) - Tuesday, 17 October 2017, 14:33 GMT
bcc also appears to be failing during linking:

/usr/lib/libLLVMSupport.a(Process.cpp.o): In function `llvm::sys::Process::FileDescriptorHasColors(int)':
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x92): undefined reference to `setupterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xb9): undefined reference to `tigetnum'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xc3): undefined reference to `set_curterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xcc): undefined reference to `del_curterm'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/cpp/CMakeFiles/CPUDistribution.dir/build.make:162: examples/cpp/CPUDistribution] Error 1
make[1]: *** [CMakeFiles/Makefile2:783: examples/cpp/CMakeFiles/CPUDistribution.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 77%] Built target bcc-shared
/usr/lib/libLLVMSupport.a(Process.cpp.o): In function `llvm::sys::Process::FileDescriptorHasColors(int)':
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x92): undefined reference to `setupterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xb9): undefined reference to `tigetnum'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xc3): undefined reference to `set_curterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xcc): undefined reference to `del_curterm'
collect2: error: ld returned 1 exit status
make[2]: *** [src/lua/CMakeFiles/bcc-lua.dir/build.make:200: src/lua/bcc-lua] Error 1
make[1]: *** [CMakeFiles/Makefile2:640: src/lua/CMakeFiles/bcc-lua.dir/all] Error 2
/usr/lib/libLLVMSupport.a(Process.cpp.o): In function `llvm::sys::Process::FileDescriptorHasColors(int)':
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x92): undefined reference to `setupterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xb9): undefined reference to `tigetnum'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xc3): undefined reference to `set_curterm'
(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0xcc): undefined reference to `del_curterm'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/cpp/CMakeFiles/FollyRequestContextSwitch.dir/build.make:162: examples/cpp/FollyRequestContextSwitch] Error 1
make[1]: *** [CMakeFiles/Makefile2:740: examples/cpp/CMakeFiles/FollyRequestContextSwitch.dir/all] Error 2
Comment by Randy Ramos (watersalesman) - Wednesday, 25 October 2017, 03:55 GMT
Two other examples of failing builds (albeit in the AUR) are https://aur.archlinux.org/packages/global/ and https://aur.archlinux.org/packages/calcurse-git/. Both fail unless I link libtinfo with the "-ltinfo" flag.
Comment by Bartłomiej Piotrowski (Barthalion) - Wednesday, 25 October 2017, 10:57 GMT
ncurses 6.0+20170902-3 fixes it, but feel free to verify, I'll wait with closing the issue.
Comment by Randy Ramos (watersalesman) - Wednesday, 25 October 2017, 12:40 GMT
I can verify that it fixes both of the builds I listed.
Comment by Earnestly (Earnest) - Wednesday, 25 October 2017, 14:18 GMT
The workaround does essentially introduce two -ltinfo flags for projects which do correctly use pkg-config or ncurses-config but that's fairly harmless.

weechat and bcc link successfully now for me, but it would still be really nice to know why termlib=tinfo was added in the first place as the commit message doesn't mention a rational.
Comment by Manu (s3gmentationfault) - Tuesday, 31 October 2017, 15:27 GMT
I had the same issue with my project using ncurses 6.0+20170902-2 after that i have upgrade my system, but the -ltinfo workaround suggested works well, thx.

However this is the error msg:
g++ -D_GNU_SOURCE -O3 -std=c++11 -o nsnake nsnake.cpp -lcrypto -lncursesw
/usr/bin/ld: /tmp/ccy42KyA.o: undefined reference to symbol 'wtimeout'
/usr/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:6: all] Error 1

Loading...