Skip to content
Latchkey

CMake "pkg-config not found" / PKG_CONFIG_EXECUTABLE-NOTFOUND in CI

find_package(PkgConfig) and pkg_check_modules need the pkg-config (or pkgconf) executable. On a slim CI image it is often missing, so the probe reports NOTFOUND.

What this error means

Configure fails because PKG_CONFIG_EXECUTABLE is NOTFOUND, or pkg_check_modules cannot locate a module, on an image without pkg-config installed.

cmake
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:99 (message):
  pkg-config tool not found

Common causes

How to fix it

Install pkg-config

  1. Install the pkg-config (or pkgconf) package before configuring.
  2. Set PKG_CONFIG_PATH if the .pc files live in a custom prefix.
cmake
apt-get install -y pkg-config
export PKG_CONFIG_PATH=/opt/lib/pkgconfig

How to prevent it

  • Install pkg-config in the runner image and set PKG_CONFIG_PATH for any dependency whose .pc files sit outside the default search path.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →