I am working from a shell script (and not an Autotools script). According to the pkg-config(1) man page, "Return meta information about installed libraries". For example, here is a check of Nettle 3.4 installed in /usr/local:

$ pkg-config --exists --print-errors "nettle >= 3.1"
$ echo $?

When I try to check Autoconf it returns an error. This is expected based on the man page:

$ pkg-config --exists --print-errors "autoconf >= 2.63"
Package autoconf was not found in the pkg-config search path.
Perhaps you should add the directory containing `autoconf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'autoconf' found

Is it possible to use pkg-config to test non-library packages? If not, is there a similar tool to supply information about installed programs?


The pkg-config tool is primarily used for querying what compiler and linker flags should be used when compiling and linking with a specific library package, while at the same time possibly asserting a specific version of said package.

The autoconf software does not provide an autoconf.pc file for pkg-config, because it does not provide headers or libraries that another program may use (similarly for automake).

Depending on what package manager your Linux uses, you may possibly use that (or some tool related to it, for example dpkg-query on Debian-based systems) to query for the status of installed packages.

  • Thanks. The distro's package tools won't help in this case because I need to know the version of the tool returned from command -v. The scripts I have are building software from sources on machines like OS X 10.5 and Solaris 10. The new software goes into /usr/local. – user56041 Jul 22 '18 at 22:11
  • @jww Umm... Why did you tag the question with "Linux" then? Also, not all utilities provide a -v option to get its version. It is further unclear now what you intend to use pkg-config for. Is it for building the software you're mentioning, or for something else? – Kusalananda Jul 22 '18 at 22:44
  • The question was tagged Linux for two reasons. First it includes old Linux systems. Second, they are GNU tools being installed by the build scripts. – user56041 Jul 22 '18 at 23:19
  • Sorry it was not clear. I wanted to use pkg-config because I don't want to write my own script to do the same job as pkg-config. For example, when building Git we can include libunistring iff Autoconf is >= 2.62. So I need to test the Autoconf version to determine if I should add --with-unistring to Git's configure options. – user56041 Jul 22 '18 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy