在 OSX 上“ pkg-config 脚本找不到”

我正在尝试在我的 Mac 上安装一些软件,但是我总是收到同样的错误:

configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.


Alternatively, you may set the environment variables XMEDCON_GLIB_CFLAGS
and XMEDCON_GLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details

我不太确定如何将 pkg-config 添加到 PATH。我在网上看到(见链接) ,我应该添加以下内容:

显示如何定向 PATH 变量的链接

export PATH=$PATH:/opt/local/bin     # Fixed typo as mentioned in comment

这是我放置 pkg-config 的地方。尽管每次尝试使用。/配置。任何帮助都将不胜感激!

217736 次浏览

Answer to my question (after several Google searches) revealed the following:

$ curl https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.29
$ ./configure && make install

from the following link: Link showing above

Thanks to everyone for their comments, and sorry for my linux/OSX ignorance!

Doing this fixed my issues as mentioned above.

if you have this error :

configure: error: Either a previously installed pkg-config or "glib-2.0 >= 2.16" could not be found. Please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure to use the bundled copy.

Instead of do this command :

$ ./configure && make install

Do that :

./configure --with-internal-glib && make install

For Ubuntu/Debian OS,

apt-get install -y pkg-config

For Redhat/Yum OS,

yum install -y pkgconfig

For Archlinux OS,

pacman -S pkgconf

for me, (OSX) the problem was solved doing this:

brew install pkg-config

Try

MacOS users

Unfortunately, pkg-config does not come with OS X by default. Here are some notes on how to compile from source. It assumes that you have Xcode installed.

  1. Download and extract
curl -O http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
tar xfz pkg-config-0.28.tar.gz
  1. Configure and Install
cd pkg-config-0.28
setenv CC /usr/bin/cc (for tcsh)
export CC=/usr/bin/cc (for bash)

2a) If you have super-user powers

./configure --prefix=/usr/local CC=$CC --with-internal-glib
make
sudo make install

2b) if not

./configure --prefix=$HOME/someplace/in/my/path CC=$CC --with-internal-glib
make
make install

Source: https://opensource.ncsa.illinois.edu/confluence/display/DESDM/Installing+pkg-config+from+source+for+OSX