我已經在 Ubuntu 12.04 中透過軟體中心安裝了 libgoogle-perftools-dev。正如建議的http://pj.freefaculty.org/blog/?p=140,我想添加到我的 cpp 檔案:
#include <gperftools/profiler.h>
但編譯器說
gperftools/profiler.h: No such file or directory
我試圖找到它在哪裡:
$ locate -i gperftools
沒有回報,並且
$ locate -i "profiler.h"
回報
/usr/include/c++/4.6/profile/impl/profiler.h
/usr/src/linux-headers-3.2.0-23-generic-pae/include/config/function/profiler.h
我不確定是否是為了gperftools
。
所以我想知道如何找到
- libgoogle-perftools-dev 安裝在哪裡?
- gperftools/profiler.h 位於哪裡?
答案1
該命令的問題可能locate
是資料庫尚未更新以反映新安裝的套件檔案。您可以強制更新 ( sudo updatedb
) 或使用該find
命令,但在像 Ubuntu 這樣使用套件管理工具的系統上,最簡單的解決方案dpkg
可能是列出套件內容
dpkg -L libgoogle-perftools-dev
或專門檢查profiler.h
文件位置
dpkg -L libgoogle-perftools-dev | grep 'profiler.h'
答案2
通常,pkg-config 在大多數情況下都會幫助
pkg-config --list-all
列出系統「已知」的軟體包。然後pkg-config --libs --cflags <package>
就足以提供連結器並包含資訊。