Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_curses fails to build on Ubuntu 22: "error: implicit declaration of function ‘setcchar’; did you mean ‘getwchar’?" #2932

Closed
samling opened this issue Mar 22, 2024 · 3 comments

Comments

@samling
Copy link

samling commented Mar 22, 2024

Platform: Ubuntu 22.04
OS architecture: amd64
Pyenv version: 2.3.36
Python version: 3.10.x
C Compiler information: gcc 11.4.0

I'm installing python 3.10.x (I've tried 3.10.12 and 3.10.14) on a more or less fresh Ubuntu 22 machine. Initially I hit the expected dependency errors detailed here, and installing the listed packages got around all but one of the errors.

The problem is that _curses fails to build, and so the installation eventually throws an error when trying to import it. I've attached the build logs and debug output.

Some relevant snippets:

Checking to make sure libncurses packages are installed (I initially tried the recommended libncursesw5 before trying the libncurses5 fallback):

❯ sudo apt-get install libncurses5 libncurses5-dev libncursesw5 libncursesw5-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libncurses5-dev is already the newest version (6.3-2ubuntu0.1).
libncursesw5-dev is already the newest version (6.3-2ubuntu0.1).
libncurses5 is already the newest version (6.3-2ubuntu0.1).
libncursesw5 is already the newest version (6.3-2ubuntu0.1).

From the build debug output:

checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
building '_curses' extension

Errors thrown during installation when attempting to build _curses:

building '_curses' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I/home/sboynton/.pyenv/versions/3.10.14/include -fPIC -DHAVE_NCURSESW=1 -I/usr/include/ncursesw -I./Include -I. -I/home/sboynton/.pyenv/versions/3.10.14/include -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/tmp/python-build.20240322105256.549130/Python-3.10.14/Include -I/tmp/python-build.20240322105256.549130/Python-3.10.14 -c /tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c -o build/temp.linux-x86_64-3.10/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.o -DPy_BUILD_CORE_MODULE
/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c: In function ‘_curses_window_addch_impl’:
/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c:760:9: error: implicit declaration of function ‘setcchar’; did you mean ‘getwchar’? [-Werror=implicit-function-declaration]
/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c:762:19: error: implicit declaration of function ‘mvwadd_wch’; did you mean ‘mvwaddch’? [-Werror=implicit-function-declaration]
/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c:764:19: error: implicit declaration of function ‘wadd_wch’; did you mean ‘waddch’? [-Werror=implicit-function-declaration]
/tmp/python-build.20240322105256.549130/Python-3.10.14/Modules/_cursesmodule.c: In function ‘_curses_window_addstr_impl’:

I appreciate any and all support. Apologies if this has been addressed somewhere else already, I searched up and down and couldn't find anything that quite matched this issue.

trace.log
python-build.20240322105256.549130.log

@native-api
Copy link
Member

native-api commented Mar 22, 2024

Please add the rest of the required diagnostic information as per the issue template, especially config.log.

@native-api
Copy link
Member

native-api commented Mar 23, 2024

Googling says this error happens due to a lack of NCURSES_WIDECHAR macro, and is usually caused by a wrong include path. Seems like you have some leftovers from a non-unicode version of ncurses on your system, probably built from source.

@samling
Copy link
Author

samling commented Mar 30, 2024

Ah, yup, your last comment pointed me in the right direction. I have a system provisioning script that, among other things, was building ncurses separately as a tmux dependency (not sure why I was doing this, works fine with the apt packages). I removed that and ~/.pyenv, reinstalled pyenv, and reinstalled 3.10.14 and the issue is resolved. Thanks!

@samling samling closed this as completed Mar 30, 2024
@native-api native-api changed the title _curses fails to build on Ubuntu 22 _curses fails to build on Ubuntu 22: "error: implicit declaration of function ‘setcchar’; did you mean ‘getwchar’?" Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants