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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7595140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:29:05  来源:igfitidea点击:

pkg-config glib-2.0 error on Mac OS X

macosglibc

提问by Snowcrash

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. And, if so, what's the best way of doing so?

在 Mac 上使用 locate 快速搜索我看不到任何 glib-2.0 文件,所以我想知道是否必须安装它。如果是这样,最好的方法是什么?

回答by johnzachary

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

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

回答by Eric

Using the --with-internal-glibflag on the ./configurecommand worked for me.

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

回答by Eric

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.

我将使用像Fink这样的系统。根据需要修补软件包并自动跟踪依赖项。这比DIY方式容易得多。

回答by Pier-Eric Chamberland

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, MacPortsor Finkfor Mac OS or ZYpp, Pacmanor YUMfor Linux. Condais also worth a look as it is python-based and can manage projects containing code written in other languages such as R.

如果没有软件包依赖项,安装就不太可能进行,安装软件包的最简单方法是使用软件包管理器,如Mac OS 的HomebrewMacPortsFink或Linux 的ZYppPacmanYUMConda也值得一看,因为它基于 Python 并且可以管理包含用其他语言(如 R)编写的代码的项目。

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

由于您的主要目标是安装gcc,brew 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.0could not be found either when installing gtkas a dependency for meson _build. However actually, I had successfully installed a more recent version of glibthe usual way, but that pkg-config was unable to find.

但是,由于您可能已经尝试过不同的安装方法,因此可能存在不同的安装路径,并且可用的软件包可能不是您当前的经理通常寻找的位置。在我的情况下,glib-2.0不能被任何安装时发现gtk,作为一个依赖meson _build。然而实际上,我已经以通常的方式成功安装了更新版本的 glib,但是 pkg-config 无法找到。

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

由于当时我是新手(现在仍然是,就像使用 stackoverflow 一样),并且由于.pc.inAutoconf 模板文件给我带来了困难,我也选择通过输入来绕过该问题,brew install gtk希望 Homebrew 能够获取所需的确切版本中glib并在最方便的包感兴趣安装。

An alternativethat was not mentioned yet was to locate any file starting with glibwithout any version number, install a current version of glibthe 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).

另一种尚未提及的替代方法是定位任何以glib不带任何版本号开头的文件,glib如果需要,以通常的方式安装当前版本,并将请求的文件添加到目录中,如错误消息所建议的那样。(我希望我当时已经理解并尝试了 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.

欢迎就如何进一步改进我的答案(形式或内容)发表评论。