centos查看哪些包提供指定头文件
【问题】:项目迁移时,原来在suse上正常的代码在centos上报错:
g++ -g -Wall -fPIC -I../include -I./ -I../src -I/share/comm_ext -I/home/appadmin/workspace/comm/export_include/ -I/home/appadmin/workspace/comm/export_include/c2cplatform -I/home/appadmin/workspace/comm/export_include/app_platform -I/home/appadmin/workspace/comm/export_include/app_platform/2.4.1 -c ../include/myutil/net_util.cpp ../include/myutil/net_util.cpp:5:21: 错误:stropts.h:没有那个文件或目录
【查找原因】
1. “stropts.h”似乎是系统提供的头文件,那么位于哪个目录下呢?
在suse上使用如下命令:
g++ -g -Wall -fPIC -I../include -I./ -I../src -I/share/comm_ext -I/home/appadmin/workspace/comm/export_include/ -I/home/appadmin/workspace/comm/export_include/c2cplatform -I/home/appadmin/workspace/comm/export_include/app_platform -I/home/appadmin/workspace/comm/export_include/app_platform/2.4.1 -E ../include/myutil/net_util.cpp >util.i
使用g++的 -E选项进行预处理(关于-E选项的更多内容,请自行搜索)
打开util.i,有如下内容:
# 1 "/usr/include/stropts.h" 1 3 4
可知在suse上该文件位于/usr/include/stropts.h
2. 再centos上查看,确实不存在/usr/include/stropts.h文件:
find /usr -name *stropts.h* find: “/usr/lib64/audit”: 权限不够
也就是说,centos上的环境确实缺少该头文件
3.既然缺少那就安装。首先需要知道的是,该头文件属于哪个包?
$ yum provides */stropts.h Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile 1:compat-glibc-headers-2.5-46.2.x86_64 : Header files for development using standard C libraries. Repo : base Matched from: Filename : /usr/lib/x86_64-redhat-linux5E/include/stropts.h Filename : /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.h Filename : /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h
可知compat-glibc-headers-2.5-46.2.x86_64包提供我们需要的头文件,我们只需要安装该包就行了。
4.先确认一下该包有没有被安装过:
$ yum list|grep installed CollabNetSubversion-client.x86_64 1.8.10-2 installed ImageMagick.x86_64 6-7 installed cpp.x86_64 4.1.2-55.el5 installed dal_auto_script.i586 1-3 installed dal_auto_script_set.i586 1-3 installed gcc.x86_64 4.1.2-55.el5 installed gcc-c++.x86_64 4.1.2-55.el5 installed libgcc.x86_64 4.1.2-55.el5 installed libstdc++.x86_64 4.1.2-55.el5 installed libstdc++-devel.x86_64 4.1.2-55.el5 installed perl_crontab.i586 1-0 installed public_scripts.i586 1-8 installed wget.x86_64 1.12-1.8.el6 installed
既然没有,那就安装吧。。。