111

I am trying to install some software on my mac; however I keep receiving the same error:

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

I am not quite sure how to go about adding the pkg-config to the PATH. I have seen online (see link) that I should add the following:

Link showing how to direct PATH variable

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

which is where I have placed pkg-config. I still keep getting the error though every time I try to configure the files using ./configure. Any help would be super appreciated!

4
  • You are missing a colon in export PATH=$PATH:/opt/local/bin. This presumes that /opt/local/bin/pkg-config exists and is the version you want.
    – tripleee
    Apr 21, 2014 at 17:22
  • My apologies for the typo. The problem is after typing this into the terminal followed by the ./configure command, I still receive this error. Any ideas as to what may be the problem?
    – Shinobii
    Apr 21, 2014 at 17:25
  • What is the output from which pkg-config?
    – StvnW
    Apr 21, 2014 at 17:48
  • '/opt/local/bin/pkgconfig/bin/pkg-config' is what I get back where my PATH is set to /opt/local/bin/pkgconfig/bin
    – Shinobii
    Apr 21, 2014 at 18:00

6 Answers 6

201

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 MacOS,

brew install pkg-config

4
  • 17
    Please note that the question was asked about osx.
    – Ali Seyedi
    Apr 6, 2016 at 3:37
  • 8
    Google still works with browsers on ubuntu though, and it landed me here. And a package-manager beats running arbitrary code curled over an insecure connection like the accepted answer suggests.
    – ivarni
    Oct 31, 2016 at 6:10
  • 1
    +1 to @AliSeyedi : The question was about OSX. I'm pretty sure that most Linux guys know how to install a package. It was not that obvious on a Mac.
    – Orabîg
    Feb 23, 2018 at 8:28
  • 4
    When I performed the command on my Ubuntu, it required root privileges, i.e.- sudo apt-get install -y pkg-config (thought it is worth to mention it). Aug 23, 2018 at 18:04
59

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

brew install pkg-config
1
41

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.

4
  • 10
    Running these commands on Ubuntu 12.04 gives the 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. Dec 11, 2014 at 18:48
  • 10
    for ubuntu you can install it with sudo apt-get install pkg-config
    – Aliza
    Jan 11, 2015 at 13:48
  • This works on Ubuntu 14.04.6 LTS, if you want 0.29 instead of the default 0.26 (which is too old to cross-compile ffmpeg with). Mar 22, 2019 at 20:41
  • Installing things with curl is very likely to end up causing a pain in the ass or breaking something in the future, and won't let you update automatically. I recommend using the answer from Stephen Hsu instead. Aug 1 at 1:38
25

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
2
2

Try

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.