简体   繁体   English

C&Mac:使用pkg-config查找标题时遇到麻烦

[英]C & Mac: trouble finding a header using pkg-config

I'm trying to use in one of my projects. 我正在尝试在我的一个项目中使用。 I'm working on a Mac, have gotten MacPorts with pkg-config and glib-2.0 packages. 我在Mac上工作,已经使用pkg-config和glib-2.0软件包获得了MacPorts。

When I try to make a file containing an include to above path, I get the following error (line above it is for clarity that it does actually give me the right dirs): 当我尝试使包含包含到上述路径的文件时,出现以下错误(为清楚起见,该行实际上确实为我提供了正确的目录):

$ pkg-config --cflags --libs glib-2.0
-I/opt/local/lib/glib-2.0/include -I/opt/local/include -L/opt/local/lib -lglib-2.0 -lintl 
$ make
gcc hash-glib.c -c `pkg-config --cflags --libs glib-2.0` -std=c99 -Wall -Wextra -pedantic -O2
hash-glib.c:2:23: error: glib/glib.h: No such file or directory
$

Presumably, you've run: 大概,您已经运行:

ls -l /opt/local/lib/glib-2.0/include/glib/glib.h \
      /opt/local/include/glib/glib.h

to demonstrate that the header #include "glib/glib.h" actually is present in one of the locations where you've been told by pkg-config that it could be found. 演示标头#include "glib/glib.h"实际上存在于pkg-config告诉您可以找到它的位置之一中。 If it isn't there, then pkg-config is misleading you, and the compiler is telling you that you've been hoodwinked. 如果不存在,则pkg-config会误导您,编译器会告诉您您被蒙蔽了。

Since the compiler will have done its utmost to find the header, it is a reasonable bet that the file isn't in either of those locations. 由于编译器将竭尽所能查找标头,因此可以合理地认为文件不在这两个位置中。 You are then left with detective work: where is the glib.h header installed? 然后,您需要进行侦探工作: glib.h标头安装在哪里?

find /opt/local -type f -name glib.h

If that tells you where it is, you can then work out what pkg-config should be saying. 如果可以告诉您它在哪里,则可以确定pkg-config应该说什么。 If that fails to find it, widen the search area. 如果找不到,请扩大搜索范围。 If you still can't find it, maybe it isn't installed yet? 如果仍然找不到它,也许它尚未安装? Or you only installed the glib runtime, not the development package. 或者,您仅安装了glib运行时,而不安装了开发包。

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

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