Repository navigation
configure doesn't disable ncurses extended_pair_content() if ncursesw is not available #123925
Copy link
Copy link
Closed
Closed
Copy link
Labels
buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
serhiy-storchaka commentedon Sep 11, 2024
What is the value of NCURSES_EXT_FUNCS and NCURSES_EXT_COLORS? How is
extended_pair_contentdefined in the header file on your system (if it is)?madscientist commentedon Sep 11, 2024
The definition of these in
curses.happears thusly:Just to note, this is by no means some bizarre custom version of Linux. This is Red Hat Enterprise Linux 8.6. The only unusual thing is that the ncursesw library is not present.
Also I see the same problem on Ubuntu 20.04, which has this version:
Right now I don't have a newer system but I can try at home later with Ubuntu 24.04 LTS.
esaaprillia commentedon Dec 11, 2024
same problem when cross compiling and building a static python3 host
pythongh-123925: Fix building curses on platforms without libncursesw
gh-123925: Fix building curses on platforms without libncursesw (GH-1…
pythongh-123925: Fix building curses on platforms without libncursesw (…
pythongh-123925: Fix building curses on platforms without libncursesw (…
[3.12] gh-123925: Fix building curses on platforms without libncursesw (
[3.13] gh-123925: Fix building curses on platforms without libncursesw (
pythongh-123925: Fix building curses on platforms without libncursesw (…