你應該做什麼取決於你的目標,我不太明白。如果您正在創建make
文件,則可能應該使用makedepend,如前面的答案中所述。
如果您想要知道系統中是否有多個版本的頭文件,請考慮使用locate
命令。例如,在我的Ubuntu 12.04 linux系統中,以下命令需要大約一秒才能完成,並生成命令下面顯示的輸出。
$ locate stdio.h | grep usr/include
/usr/include/stdio.h
/usr/include/c++/4.6/tr1/stdio.h
/usr/include/glib-2.0/glib/gstdio.h
/usr/include/sharutils/stdio.h
/usr/include/x86_64-linux-gnu/bits/stdio.h
如果您有關於文件PQR的單獨的行庫的路徑列表,和頭文件在文件XYZ的列表,你可以使用如下命令
locate/| grep -f xyz | grep -f pqr
(注意,-F
可能與-f
沿如果你喜歡隨着xyz
在pqr
兩行(stdio.h
和stdlib.h
)和兩行(/usr/include/
/usr/lib/
和)一起使用。),該命令需要0.7秒我的系統中,以產生輸出
/usr/include/stdio.h
/usr/include/stdlib.h
/usr/include/c++/4.6/tr1/stdio.h
/usr/include/c++/4.6/tr1/stdlib.h
/usr/include/freetype2/freetype/config/ftstdlib.h
/usr/include/glib-2.0/glib/gstdio.h
/usr/include/sharutils/stdio.h
/usr/include/sharutils/stdlib.h
/usr/include/x86_64-linux-gnu/bits/stdio.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/lib/perl/5.14.2/CORE/nostdio.h
/usr/lib/syslinux/com32/include/stdio.h
/usr/lib/syslinux/com32/include/stdlib.h
請注意,在典型的linux系統上,文件名數據庫每天更新一次。這在查找系統頭文件時可能不會有問題。對於更短暫的文件,在使用locate
之前,您可能需要說sudo updatedb
,並且這會在整個時間內增加幾秒到幾分鐘的時間。
感謝您的評論,lynxlynxlynx,它幫助了很多。我會盡力按照你的建議=) – petajamaja