简体   繁体   English

Mac OS X 上的 pkg-config glib-2.0 错误

[英]pkg-config glib-2.0 error on Mac OS X

I've got some C code which won't compile.我有一些无法编译的 C 代码。

The error message when I run "make" is:运行“make”时的错误消息是:

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.在 Mac 上使用 locate 快速搜索我看不到任何 glib-2.0 文件,所以我想知道是否必须安装它。 And, if so, what's the best way of doing so?如果是这样,最好的方法是什么?

最简单的解决方案:安装 Homebrew,输入brew install glib ,你应该很高兴。

./configure命令上使用--with-internal-glib标志对我./configure

I'll use a system like Fink .我将使用像Fink这样的系统。 The packages are patched as necessary and dependencies are tracked automatically.根据需要修补软件包并自动跟踪依赖项。 It is a lot easier than the DIY way.这比DIY方式容易得多。

To strictly answer the '2011 question:严格回答'2011问题:

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.如果没有软件包依赖项,安装就不太可能进行,安装软件包的最简单方法是使用软件包管理器,如 Mac OS 的HomebrewMacPortsFink或 Linux 的ZYppPacmanYUM Conda is also worth a look as it is python-based and can manage projects containing code written in other languages such as R. Conda也值得一看,因为它基于 Python 并且可以管理包含用其他语言(如 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.由于您的主要目标是安装gccbrew install gcc可以解决这个问题,并将获取glib等依赖项并将它们放在以后可以找到的地方。

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:假设最近的读者(新手和高级)正在尝试根据自己的需求调整 OP 问题和答案,这里有更多,以及个人上下文信息:

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 .在我的情况下,在安装gtk作为meson _build的依赖项时也找不到glib-2.0 However actually, I had successfully installed a more recent version of glib the usual way, but that pkg-config was unable to find.但是实际上,我已经以通常的方式成功安装了更新版本的 glib ,但是 pkg-config 无法找到。

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.由于我当时是新手(现在仍然是,就像使用 stackoverflow 一样),并且因为.pc.in Autoconf 模板文件给我带来了困难,我也选择通过输入brew install gtk来绕过这个问题,希望Homebrew 将获取glib所需的确切版本,并将其安装在对感兴趣的包最方便的地方。

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.另一种尚未提及的替代方法是找到任何以glib开头但没有任何版本号的文件,如果需要,以通常的方式安装当前版本的glib ,然后按照错误消息的建议将请求的文件添加到目录中。 (I wish I had understood and tried Eric and Nathan's solution at the time). (我希望我当时已经理解并尝试了 Eric 和 Nathan 的解决方案)。

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.您可以通过键入export PKG_CONFIG_PATH=/full/directory/path/to/yourfile来添加目录,但查阅有关该主题的专用帮助页面是安全的。

Comments on how to further improve my answer (form or content) are much welcome.欢迎就如何进一步改进我的答案(形式或内容)发表评论。

Answer for internet searching this,互联网搜索的答案,

In linux在 linux 中

sudo apt-get install libgtk2.0-dev sudo apt-get install libgtk2.0-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM