Python compilation, curses.h not found
I am trying to build Python 2.6.2 from source on my Linux system. It has ncurses installed at / usr / local / and curses.h is located in / usr / local / include / ncurses. So curses.h was not found in the include path and these packages do not work in Python builds.
What's the correct decision? Is Python supposed to include <ncurses / curses.h>? Should / usr / local / include / ncurses be in the include path? Should there be a link from files in the ncurses directory to / usr / local / include?
Or is there an easier solution?
a source to share
In many open source packages, you can install:
export CPPFLAGS="-I/usr/local/include"
or even:
export CPPFLAGS="-I/usr/local/include/ncurses"
before running the configure script. I haven't compiled Python recently enough to be sure it works, but it probably does - I have ncurses installed in / usr / gnu (because / usr / local / is auto-mounted and contains antiques) and I don't remember to use something special to make it work.
Double checked ...
The config script only includes <curses.h>
. I had to use:
export CPPFLAGS="-I/usr/gnu/include -I/usr/gnu/include/ncurses"
export LDFLAGS="-L/usr/gnu/lib"
./configure
To set up Python (2.5) to accept curses. You would replace " gnu
" with " local
" for your configuration.
a source to share
I know this is a very old question, but the problem still occurred when compiling python 3.6.0 from source, so I think this is still relevant.
Recent versions of ncurses come in several flavors: normal, wide character support, streaming. To allow programmers to save and use different options besides naming libraries differently ( ncursesw.so
, ncursest.so
etc.), the ncurses configure script installs a makefile to place the header files in subdirectories by default. It also allows you to have various curses implementations along with ncurses, as indicated in the man page .
However, some programs still assume that curses.h
, for all other ncurses headers, they are located at the top level, including search paths, and will not search subdirectories. Many Linux distributions usually have some kind of workaround in the ncurses development packages, but if you are compiling ncurses from source, there are two possible approaches to solving the problem:
- Usage
CPPFLAGS
or equivalent as the accepted answer suggests. It works, but you have to set the appropriate compilation flags each time. - Setting up ncurses with
--enable-overwrite
. This will install the ncurses header files in the top level directory, according to yours--prefix
.
Unless you plan on installing an alternative curses library, it is perfectly safe to put the ncurses headers at the top level including the path, and this is the approach Gentoo follows .
a source to share