Closed
Description
Bug report
Bug description:
On a system I'm trying to build Python for, I have libncurses.so available but not libncursesw.so.
Unfortunately, although this is not documented directly anywhere I can find, the ncurses extended_pair_content() and extended_color_content() functions (and the init_extended_*()
functions) are not available in libncurses, they are only available in libncursesw. This causes the compilation of Python to fail:
checking for curses.h... yes checking for ncurses.h... yes checking for ncursesw... no checking for initscr in -lncursesw... no checking for ncurses... no checking for initscr in -lncurses... yes checking curses module flags... ncurses (CFLAGS: , LIBS: -lncurses) checking for panel.h... yes checking for panel... no checking for update_panels in -lpanel... yes checking panel flags... panel (CFLAGS: , LIBS: -lpanel) checking for term.h... yes checking whether mvwdelch is an expression... yes checking whether WINDOW has _flags... yes checking for curses function is_pad... yes checking for curses function is_term_resized... yes checking for curses function resize_term... yes checking for curses function resizeterm... yes checking for curses function immedok... yes checking for curses function syncok... yes checking for curses function wchgat... yes checking for curses function filter... yes checking for curses function has_key... yes checking for curses function typeahead... yes checking for curses function use_env... yes ... checking for stdlib extension module _curses... yes checking for stdlib extension module _curses_panel... yes ... 86_64-rl84-linux-gnu-gcc -pthread -shared Modules/_cursesmodule.o -lncurses -o Modules/_curses.cpython-312-x86_64-linux-gnu.so ... ./python -E -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.% d" % (get_platform(), *sys.version_info[:2]))' >platform [ERROR] _curses failed to import: /data/src/python3/Linux-Release-make/bld.python3/build/lib.linux-x86_64-3.12/_curses.cpython-312-x86_64-linux-gnu.so: undefined symbol: extended_pair_content
If I try a simple program:
#include <ncurses.h> #include <stdio.h> int main(void) { initscr(); start_color(); { int f, b; int r = extended_pair_content(1, &f, &b); printf("r=%d f=%d b=%d\n", r, f, b); } endwin(); return 0; }
then it works if I link with -lncursesw
:
$ gcc -o /tmp/foo /tmp/foo.c -lncursesw $
But fails if I only link with -lncurses
:
$ gcc -o /tmp/foo /tmp/foo.c -lncurses /bin/ld: /tmp/cccHNZsN.o: in function `main': foo.c:(.text+0x85): undefined reference to `extended_pair_content' /bin/ld: foo.c:(.text+0x107): undefined reference to `extended_color_content' collect2: error: ld returned 1 exit status $
I believe this patch will fix it:
--- a/Modules/_cursesmodule.c 2024-09-06 15:03:47.000000000 -0400 +++ b/Modules/_cursesmodule.c 2024-09-10 17:41:55.124440110 -0400 @@ -139,7 +139,7 @@ #define STRICT_SYSV_CURSES #endif -#if NCURSES_EXT_FUNCS+0 >= 20170401 && NCURSES_EXT_COLORS+0 >= 20170401 +#if HAVE_NCURSESW && NCURSES_EXT_FUNCS+0 >= 20170401 && NCURSES_EXT_COLORS+0 >\ = 20170401 #define _NCURSES_EXTENDED_COLOR_FUNCS 1 #else #define _NCURSES_EXTENDED_COLOR_FUNCS 0
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done