开发者

pkg-config glib-2.0 error on Mac OS X

I've got some C code which won't compile.

The error message when I run "make开发者_运维技巧" is:

gcc -Wall -Wno-pointer-sign -g `pkg-config --cflags glib-2.0 gconf-2.0`
 \      -c main.c Package glib-2.0 was not found in the pkg-config search
path. Perhaps you should add the directory containing `glib-2.0.pc' to
the PKG_CONFIG_PATH environment variable No package 'glib-2.0' found

Doing a quick search on the Mac using locate I can't see any glib-2.0 files so I'm wondering if I have to install it. And, if so, what's the best way of doing so?


Easiest solution: install Homebrew, type brew install glib, and you should be good to go.


Using the --with-internal-glib flag on the ./configure command worked for me.


I'll use a system like Fink. The packages are patched as necessary and dependencies are tracked automatically. It is a lot easier than the DIY way.


To strictly answer the '2011 question:

Installation is unlikely to proceed without package dependencies, and the easiest way to install a package is to use a package manager like Homebrew, MacPorts or Fink for Mac OS or ZYpp, Pacman or YUM for Linux. Conda is also worth a look as it is python-based and can manage projects containing code written in other languages such as R.

As your primary goal is to install gcc, brew install gcc could do the trick and will fetch dependencies such as glib and put them where it can find it later.

Assuming recent readers (novice and advanced) are trying to adapt the OP problem and answers to their own needs, here is more, along with personal contextual information:

However, as you may have experimented with different installation methods already, different installation paths may exist and available packages may not be where your current manager is normally looking for. In my case, glib-2.0 could not be found either when installing gtk as a dependency for meson _build. However actually, I had successfully installed a more recent version of glib the usual way, but that pkg-config was unable to find.

As I was novice at the time (and still am, like with stackoverflow), and as a .pc.in Autoconf template file was giving me a hard time, I also chose to bypass the issue by entering brew install gtk in the hope that Homebrew would fetch the exact version needed of glib and install it where most convenient for the package of interest.

An alternative that was not mentioned yet was to locate any file starting with glib without any version number, install a current version of glib the usual way if needed, and add the requested file to the directory, as suggested by the error message. (I wish I had understood and tried Eric and Nathan's solution at the time).

You can add a directory by typing export PKG_CONFIG_PATH=/full/directory/path/to/yourfile, but it would be safe to consult dedicated help pages on the topic.

Comments on how to further improve my answer (form or content) are much welcome.


Answer for internet searching this,

In linux

sudo apt-get install libgtk2.0-dev

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜