pkg-config: command not found during compile, but pkg-config installed

eyests picture eyests · Mar 6, 2016 · Viewed 13.9k times · Source

Update: I got it working, the problem has something to do with the fact that I was running it through emacs. I ran the makefile from the command line instead, and pkg-config ran. After adding the path to guile-2.0.pc with export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig everything compiled and ran OK. Still won't compile through emacs but I don't want to deal with that.

I am trying to compile a C program but received a "pkg-config: command not found" error, but am pretty sure pkg-config is installed.

Below is the MAKEFILE

# Use GCC, if you have it installed.
CC=gcc

# Tell the C compiler where to find <libguile.h>
CFLAGS=`pkg-config --cflags guile-2.0`

# Tell the linker what libraries to use and where to find them.
LIBS=`pkg-config --libs guile-2.0`

simple-guile: simple-guile.o
${CC} simple-guile.o ${LIBS} -o simple-guile

simple-guile.o: test.c
${CC} -c ${CFLAGS} test.c

Below is the error message (re: second error, I think if I can resolve this issue the libguile.h file will be found)

make 
gcc -c `pkg-config --cflags guile-2.0` test.c
/bin/sh: pkg-config: command not found
test.c:2:11: fatal error: 'libguile.h' file not found
 #include <libguile.h> 
      ^
1 error generated.
make: *** [simple-guile.o] Error 1    

I installed pkg-config by

brew install pkg-config

Installation appears successful?...

Jeffs-iMac:~ Jeff$ which pkg-config
/opt/local/bin/pkg-config

If it's relevant, this should be the same directory in which guile is located:

Jeffs-iMac:~ Jeff$ which guile
/opt/local/bin/guile

Am using OS X 10.11.3

I tried uninstalling and reinstalling pkg-config per: Can't install rmagick, pkg-config: command not found

I'm a novice programmer, any help would be greatly appreciated.

Answer