Question

I'm attempting to build Python 2.6.2 from source on my Linux system. It has ncurses installed on /usr/local/, and curses.h is on /usr/local/include/ncurses. So curses.h isn't found on the include path, and those packages fail in the Python build.

What's the right solution to this? Is Python supposed to include <ncurses/curses.h>? Should /usr/local/include/ncurses be in the include path? Should there be a link from the files in the ncurses directory to /usr/local/include?

Or is there some simpler solution?

Was it helpful?

Solution

With many Open Source packages, you can set:

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 that works, but it probably does -- I have ncurses installed under /usr/gnu (because /usr/local/ is automounted and contains antiques) and I don't remember having to use anything special to get it to work.


Double-checked...

The configure 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 get the Python (2.5) configure to accept curses. You'd replace 'gnu' with 'local' for your configuration.

OTHER TIPS

I know this is a very old question, but the problem still occurred to me when compiling python 3.6.0 from source so I guess it's still relevant.

Recent versions of ncurses come in several flavors: normal, wide character support, threaded. In order to allow programmers to keep and use different flavors, besides naming the libraries differently (ncursesw.so, ncursest.so, etc), the ncurses configure script sets up the makefile to put the header files in subdirectories by default. This also allows to have different curses implementations alongside ncurses, as specified in the man page.

Some programs, however, still assume that curses.h, along all other ncurses headers, are placed in the top level include search paths, and won't look into subdirectories. In many linux distributions there is usually some sort of workaround for the problem in ncurses developement packages, but if you are compiling ncurses from source, there are two possible approaches to solve the issue:

  1. Using CPPFLAGS or equivalent, as the accepted answer suggests. It works, but you have to set the appropriate compilation flags every time.
  2. Configuring ncurses with --enable-overwrite. This will install the ncurses header files in the top level include directory, according to your --prefix.

If you don't plan to install an alternate curses library, it's completely safe to put the ncurses headers in the top level include path, and it is the approach followed by Gentoo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top