Using the pkg-config macro PKG_CHECK_MODULES failing
Asked Answered
M

2

12

I'm sure this is a fairly simple problem. I have a very simple configure.ac file which I am using to just learn how autoconf & pkg-config work together. The confgure.ac file looks like:

AC_PREREQ(2.61)
AC_INIT(autoconf_test, 1.0, [email protected])

PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)

I can then execute autoconf from the command line and it does produce a configure script. However, when I run the configure script, I get the following error:

./configure: line 1618: syntax error near unexpected token `libusbmuxd,'
./configure: line 1618: `PKG_CHECK_MODULES(libusbmuxd, libusbmuxd >= 0.1.4)'

If I use the pkg-config program from the command line to check to see whether it can find this library, it succeeds.

/usr/lib/pkgconfig $pkg-config --libs --cflags --modversion libusbmuxd

1.0.7
-I/usr/local/Cellar/usbmuxd/1.0.7/include  -L/usr/local/Cellar/usbmuxd/1.0.7/lib -lusbmuxd  

So, it seems clear that for some reason the PGK_CHECK_MODULE macro cannot be located and I am not sure why.

This probably isn't OS specific, but I am using Mac OS X 10.6.8.

Maible answered 20/12, 2011 at 15:54 Comment(3)
The macro is in a file pkg.m4 if I'm not wrong. Can you find this file somewhere in /usr/share/aclocal or a similar directory?Heirloom
Use 'aclocal --print' to determine the directory in which to look for pkg.m4Knowledge
How did you install pkg-config, and how did you install the autotools?Homans
K
22

When you are bootstrapping (ie, running autoreconf), aclocal is unable to find pkg.m4. This is because pkg-config was either not installed or has been installed somewhere that aclocal does not know about. (ie, it was installed with a different prefix than automake.) To solve this, you need to find where pkg-config installed pkg.m4 and add that directory to the search path. eg, if pkg-config installed $HOME/share/aclocal/pkg.m4, you should run autoreconf -I$HOME/share/aclocal

There is actually a large school of thought that says that the best way to use pkg-config with the autotools is to not use it. If you look through the autoconf mailing list archive, you will see this debated ad-nauseum. Be aware that many people do recommend avoiding it completely.

Knowledge answered 21/12, 2011 at 11:43 Comment(0)
P
1

It seems the homebrew people decided this wasn't their problem and swept it into a warning. super frustrating since no one will see since no one is using homebrew or automake and expecting to have to dig deep into the details of what is wrong. Here's the link.

Pantia answered 2/2, 2016 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.