我在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我错过了什么?图书馆在哪里?
sudo apt-get install libreadline6
#include <readline/readline.h>
#include <readline/history.h>
-Wall -Wextra -Werror -g -lreadline
readline/readline.h: No such file or directory
syqv5f0l1#
安装开发包:libreadline-dev。您只安装了运行时包(它不包括头文件,因为运行时不需要这些文件)。
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
/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 ...
1条答案
按热度按时间syqv5f0l1#
安装开发包:
libreadline-dev
。您只安装了运行时包(它不包括头文件,因为运行时不需要这些文件)。检查您从
libreadline-dev
软件包中得到了什么(您错过的文件被标记为*
):pkg-config --cflags --libs readline
的输出将为您提供必要的包含路径选项、定义和链接选项(来自上面列出的文件/usr/lib/x86_64-linux-gnu/pkgconfig/readline.pc
)。可能的输出:然后编译和链接: