雖然一度通過
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
把glib-2.0.pc這個文件的路徑/usr/local/lib/pkgconfig加到PKG_CONFIG_PATH這個環境變量中而解決了這個問題,但是重啓後發現方法失效了,再次./configre依然會報出如題的錯誤。
原因是 The environment variables you set this way are valid only while your current shell is open. Once you close it, or if you open another shell, you must reset the variables. Alternately, you can add the variables to your ~/ .bashrc file or /etc/profile (this may vary depending on your OS) so they can initialize with each shell.
最後終於在網上找到一篇詳細說明這個問題的文章:關係到能否成功編譯 /etc /ld.so.conf ; ldconfig ; PKG_CONFIG_PATH