简体   繁体   中英

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.

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. If it isn't there, then pkg-config is misleading you, and the compiler is telling you that you've been hoodwinked.

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?

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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