標籤:
【問題】:項目遷移時,原來在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.hLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile1:compat-glibc-headers-2.5-46.2.x86_64 : Header files for development using standard C libraries.Repo : baseMatched from:Filename : /usr/lib/x86_64-redhat-linux5E/include/stropts.hFilename : /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.hFilename : /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h
可知compat-glibc-headers-2.5-46.2.x86_64包提供我們需要的標頭檔,我們只需要安裝該包就行了。
4.先確認一下該包有沒有被安裝過:
$ yum list|grep installedCollabNetSubversion-client.x86_64 1.8.10-2 installedImageMagick.x86_64 6-7 installedcpp.x86_64 4.1.2-55.el5 installeddal_auto_script.i586 1-3 installeddal_auto_script_set.i586 1-3 installedgcc.x86_64 4.1.2-55.el5 installedgcc-c++.x86_64 4.1.2-55.el5 installedlibgcc.x86_64 4.1.2-55.el5 installedlibstdc++.x86_64 4.1.2-55.el5 installedlibstdc++-devel.x86_64 4.1.2-55.el5 installedperl_crontab.i586 1-0 installedpublic_scripts.i586 1-8 installedwget.x86_64 1.12-1.8.el6 installed
既然沒有,那就安裝吧。。。
centos查看哪些包提供指定標頭檔