在ubuntu中我在哪里可以找到c readline库?

y3bcpkx1  于 2022-11-28  发布在  其他
关注(0)|答案(1)|浏览(206)

我在Ubuntu 20.04.5 LTS上,我已经完成了:
sudo apt-get install libreadline6
然而,vs代码无法识别#include <readline/readline.h>#include <readline/history.h>
又叫闹着:
-Wall -Wextra -Werror -g -lreadline
给我readline/readline.h: No such file or directory
我错过了什么?图书馆在哪里?

syqv5f0l

syqv5f0l1#

安装开发包:libreadline-dev。您只安装了运行时包(它不包括头文件,因为运行时不需要这些文件)。

$ sudo apt install libreadline-dev
...

检查您从libreadline-dev软件包中得到了什么(您错过的文件被标记为*):

$ dpkg -L libreadline-dev
/.
/usr
/usr/include
/usr/include/readline
/usr/include/readline/chardefs.h
/usr/include/readline/history.h                    *
/usr/include/readline/keymaps.h
/usr/include/readline/readline.h                   *
/usr/include/readline/rlconf.h
/usr/include/readline/rlstdc.h
/usr/include/readline/rltypedefs.h
/usr/include/readline/tilde.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libhistory.a
/usr/lib/x86_64-linux-gnu/libreadline.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/readline.pc
/usr/share
/usr/share/doc
/usr/share/info
/usr/lib/x86_64-linux-gnu/libhistory.so
/usr/lib/x86_64-linux-gnu/libreadline.so
/usr/share/doc/libreadline-dev

pkg-config --cflags --libs readline的输出将为您提供必要的包含路径选项、定义和链接选项(来自上面列出的文件/usr/lib/x86_64-linux-gnu/pkgconfig/readline.pc)。可能的输出:

$ pkg-config --cflags --libs readline
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lreadline

然后编译和链接:

$ gcc $(pkg-config --cflags --libs readline) -lhistory -Wall -Wextra ...

相关问题