编译Python,找不到curses.h

发布于 2024-07-20 10:20:01 字数 345 浏览 9 评论 0原文

我正在尝试在我的 Linux 系统上从源代码构建 Python 2.6.2。 ncurses 安装在 /usr/local/ 上,curses.h 位于 /usr/local/include/ncurses 上。 因此,在包含路径中找不到curses.h,并且这些包在Python 构建中失败。

对此正确的解决方案是什么? Python 应该包含吗? /usr/local/include/ncurses 应该在包含路径中吗? ncurses 目录中的文件是否应该存在到 /usr/local/include 的链接?

或者有一些更简单的解决方案吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唯憾梦倾城 2024-07-27 10:20:01

对于许多开源软件包,您可以

export CPPFLAGS="-I/usr/local/include"

设置:甚至: 。

export CPPFLAGS="-I/usr/local/include/ncurses"

在运行配置脚本之前 我最近还没有编译 Python 足以确保其有效,但它可能确实有效 - 我在 /usr/gnu 下安装了 ncurses (因为 /usr/local/ 是自动安装的并且包含古董)并且我不记得必须这样做使用任何特殊的东西来让它工作。


仔细检查...

配置脚本仅包含 。 我必须使用:

export CPPFLAGS="-I/usr/gnu/include -I/usr/gnu/include/ncurses"
export LDFLAGS="-L/usr/gnu/lib"
./configure

让Python(2.5)配置接受诅咒。 您可以将配置中的“gnu”替换为“local”。

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.

却一份温柔 2024-07-27 10:20:01

我知道这是一个非常老的问题,但是当我从源代码编译 python 3.6.0 时仍然出现这个问题,所以我想它仍然相关。

ncurses 的最新版本有多种风格:普通、宽字符支持、线程。 为了允许程序员保留和使用不同的风格,除了以不同的方式命名库(ncursesw.so、ncursest.so 等)之外,ncurses 配置脚本还设置了makefile 默认将头文件放在子目录中。 这还允许与 ncurses 一起具有不同的 curses 实现,如手册页中指定的那样。

然而,某些程序仍然假设 curses.h 与所有其他 ncurses 标头一起放置在顶级包含搜索路径中,并且不会查找子目录。 在许多 Linux 发行版中,ncurses 开发包中通常有某种解决该问题的方法,但如果您从源代码编译 ncurses,则有两种可能的方法来解决该问题:

  1. 使用 CPPFLAGS 或等效方法,正如已接受的答案所暗示的那样。 它可以工作,但是您每次都必须设置适当的编译标志。
  2. 使用 --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:

  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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文