GNU readline 历史功能

发布于 2024-07-25 19:09:08 字数 634 浏览 1 评论 0原文

我将此代码用于 shell 中的历史记录功能: http ://cc.byexamples.com/20080613/gnu-readline-how-to-keep-a-history-list-of-entered-command-lines/ 但是当我使用 gcc 编译它时,我得到了这个错误

$ gcc filename.c
/tmp/ccay2CgM.o: In function `main':
rl.c:(.text+0x9): undefined reference to `rl_abort'
rl.c:(.text+0x13): undefined reference to `rl_bind_key'
rl.c:(.text+0x1d): undefined reference to `readline'
rl.c:(.text+0x61): undefined reference to `add_history'
collect2: ld returned 1 exit status
$

I'm using this code for the history features in my shell:
http://cc.byexamples.com/20080613/gnu-readline-how-to-keep-a-history-list-of-entered-command-lines/
but when I compile this using gcc, I got this error

$ gcc filename.c
/tmp/ccay2CgM.o: In function `main':
rl.c:(.text+0x9): undefined reference to `rl_abort'
rl.c:(.text+0x13): undefined reference to `rl_bind_key'
rl.c:(.text+0x1d): undefined reference to `readline'
rl.c:(.text+0x61): undefined reference to `add_history'
collect2: ld returned 1 exit status
$

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

夏花。依旧 2024-08-01 19:09:08

示例编译行是

g++ -o simple_rl{,.cpp} -lreadline

您忘记添加 -lreadline 了吗?

The example compile line is

g++ -o simple_rl{,.cpp} -lreadline

Did you forget to add the -lreadline?

娇俏 2024-08-01 19:09:08

编译如下:

gcc -lreadline -lncurses -o simple_rl{,.cpp}

Compile with this:

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