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

发布于 2024-12-07 07:38:30 字数 438 浏览 5 评论 0 原文

我有一些无法编译的 C 代码。

当我运行“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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不顾 2024-12-14 07:38:30

最简单的解决方案:安装 Homebrew,输入 brew install glib,然后就可以开始了。

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

尘曦 2024-12-14 07:38:30

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

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

我是有多爱你 2024-12-14 07:38:30

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

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.

〆一缕阳光ご 2024-12-14 07:38:30

严格回答 '2011 问题:

如果没有软件包依赖项,安装不可能继续进行,安装软件包的最简单方法是使用像 HomebrewMacPortsFink for Mac OS 或 ZYppPacmanYUM 适用于 Linux。 Conda 也值得一看,因为它基于 python,可以管理包含用其他语言编写的代码的项目,例如由于

您的主要目标是安装 gcc,因此 brew install gcc 可以实现这一目的,并会获取诸如 glib 之类的依赖项并将其放入稍后可以在哪里找到它。

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

但是,由于您可能已经尝试过不同的安装方法可能已经存在不同的安装路径,并且可用的软件包可能不是您当前的经理通常寻找的位置。
就我而言,在将 gtk 安装为 meson _build 的依赖项时,也找不到 glib-2.0。但实际上,我已经按照通常的方式成功安装了 更新版本的 glib ,但是 pkg-配置无法找到。

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

尚未提及的替代方案是找到以glib开头且不带任何版本号的任何文件,以通常的方式安装当前版本的glib如果需要,并将请求的文件添加到目录中,如错误消息所示。 (我希望我当时已经理解并尝试了埃里克和内森的解决方案)。

您可以通过输入 export PKG_CONFIG_PATH=/full/directory/path/to/yourfile 添加目录,但查阅有关该主题的专用帮助页面是安全的。

非常欢迎有关如何进一步改进我的答案(形式或内容)的评论。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文