编译Python,找不到curses.h
我正在尝试在我的 Linux 系统上从源代码构建 Python 2.6.2。 ncurses 安装在 /usr/local/ 上,curses.h 位于 /usr/local/include/ncurses 上。 因此,在包含路径中找不到curses.h,并且这些包在Python 构建中失败。
对此正确的解决方案是什么? Python 应该包含
或者有一些更简单的解决方案吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于许多开源软件包,您可以
设置:甚至: 。
在运行配置脚本之前 我最近还没有编译 Python 足以确保其有效,但它可能确实有效 - 我在 /usr/gnu 下安装了 ncurses (因为 /usr/local/ 是自动安装的并且包含古董)并且我不记得必须这样做使用任何特殊的东西来让它工作。
仔细检查...
配置脚本仅包含
。 我必须使用:让Python(2.5)配置接受诅咒。 您可以将配置中的“
gnu
”替换为“local
”。With many Open Source packages, you can set:
or even:
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:To get the Python (2.5) configure to accept curses. You'd replace '
gnu
' with 'local
' for your configuration.我知道这是一个非常老的问题,但是当我从源代码编译 python 3.6.0 时仍然出现这个问题,所以我想它仍然相关。
ncurses 的最新版本有多种风格:普通、宽字符支持、线程。 为了允许程序员保留和使用不同的风格,除了以不同的方式命名库(ncursesw.so、ncursest.so 等)之外,ncurses 配置脚本还设置了makefile 默认将头文件放在子目录中。 这还允许与 ncurses 一起具有不同的 curses 实现,如手册页中指定的那样。
然而,某些程序仍然假设
curses.h
与所有其他 ncurses 标头一起放置在顶级包含搜索路径中,并且不会查找子目录。 在许多 Linux 发行版中,ncurses 开发包中通常有某种解决该问题的方法,但如果您从源代码编译 ncurses,则有两种可能的方法来解决该问题:--enable-overwrite
配置 ncurses。 这将根据您的--prefix
在顶级包含目录中安装 ncurses 头文件。如果您不打算安装备用的 Curses 库,则将 ncurses 标头放在顶级包含路径中是完全安全的,这是 Gentoo。
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:CPPFLAGS
or equivalent, as the accepted answer suggests. It works, but you have to set the appropriate compilation flags every time.--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.