1

我正在使用安装了 quicklisp 的 cl-ncurses 在 Ubuntu 13.04 上运行从 apt 安装的 SBCL,并且我遇到了通过 UFFI 加载本机 ncurses 的问题。

初始会话是这样的:

This is SBCL 1.1.1.0.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
\* (asdf:oos 'asdf:load-op :cl-ncurses)
WARNING: Unable to load ncurses.

这是正确的,因为尝试运行 ncurses 相关代码会产生:

debugger invoked on a SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR in thread
#<THREAD "main thread" RUNNING {10029C0E83}>:
  Attempt to call an undefined alien function.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR)

如果我尝试手动加载它(从 cl-ncurse 的 package.lisp 中窃取相关代码),我会得到以下结果:

\* (asdf:load-system 'uffi)

T
\* (uffi:find-foreign-library "libncurses" '("/usr/local/lib64/" "/usr/local/lib/" "/lib64/" "/lib/" "/usr/lib64/" "/usr/lib/" "/usr/lib32" "/usr/lib/x86_64-linux-gnu") :types '("so" "a"))

NIL

我在其中添加了最后两个搜索路径。libncurses5-dev 已安装并且在 ncurses 上运行的应用程序运行良好。试图在我的机器上找到 .so 文件,我得到:

% locate libncurses.so
/lib/i386-linux-gnu/libncurses.so.5
/lib/i386-linux-gnu/libncurses.so.5.9
/lib/x86_64-linux-gnu/libncurses.so.5
/lib/x86_64-linux-gnu/libncurses.so.5.9
/lib32/libncurses.so.5
/lib32/libncurses.so.5.9
/usr/lib/x86_64-linux-gnu/libncurses.so
/usr/lib32/libncurses.so

到达 libncurses.so 的路径包含在搜索路径中。关于如何让 UFFI 加载 ncurses 的任何想法?

4

1 回答 1

1

我最终通过添加符号链接来实现这一点,如下所示:

% sudo ln -s /lib/x86_64-linux-gnu/libncurses.so.5.9 /usr/lib/libncurses.so 

符号链接 64 位版本而不是 32 位版本很重要。这个想法来自这个github页面:

https://github.com/chadbraunduin/hackernews

于 2013-07-03T03:20:58.633 回答