Could not find a package configuration file C/C++ Origin: Application & API Last updated 15 Oct 2026

CMake Error: Could not find a package configuration file provided by "Foo" (requested version 1.2)

find_package(Foo) could not locate the library's CMake config (FooConfig.cmake or FindFoo.cmake), so the library is not installed or CMake is not told where it is.

Exact message you may see Could not find a package configuration file provided byBy not providing "FindFoo.cmake" in CMAKE_MODULE_PATHAdd the installation prefix of "Foo" to CMAKE_PREFIX_PATHCMake Error at CMakeLists.txt: find_packageCould NOT find OpenSSL (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
Seen on: C/C++ CMake Linux

Meaning

CMake searches standard prefixes plus CMAKE_PREFIX_PATH, <Package>_DIR and the system package registry. Install the library's development package, or point CMake at the install prefix. For libraries that provide only pkg-config files, use find_package(PkgConfig).

Common causes

  • Development package not installed (libfoo-dev, foo-devel, Homebrew formula)
  • Library installed in a custom prefix CMake does not search
  • Wrong package name or case (OpenCV vs opencv)
  • Version requested is higher than the installed one
  • Package ships only a pkg-config file, no CMake config

⚡ Quick fix

  1. Install the development package or build the library and cmake --install it
  2. Pass the prefix: cmake -DCMAKE_PREFIX_PATH=/opt/foo .. or -DFoo_DIR=/opt/foo/lib/cmake/Foo
  3. Check the exact package name in the library docs

Detailed fix by platform

CMake

  1. cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/foo
  2. Debug the search: cmake --debug-find -S . -B build (3.17+)
  3. For pkg-config libraries: find_package(PkgConfig REQUIRED) + pkg_check_modules(FOO REQUIRED foo)

Linux

  1. apt search libfoo-dev / dnf search foo-devel to find the package; find / -name "FooConfig.cmake" 2>/dev/null to locate an existing install

Code examples

Telling CMake where the package is

cmake
cmake_minimum_required(VERSION 3.16)
project(app)

find_package(Foo 1.2 REQUIRED)               # looks for FooConfig.cmake
add_executable(app main.cpp)
target_link_libraries(app PRIVATE Foo::Foo)

# configure with:
#   cmake -S . -B build -DCMAKE_PREFIX_PATH=/opt/foo

How to diagnose

  1. Name — Exact package name in the docs?
  2. Install — Is FooConfig.cmake on disk?
  3. Prefix — Is its prefix in CMAKE_PREFIX_PATH?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

fatal error: No such file or directory — C/C++: fatal error: foo.h: No such file or directory — #include not found (C/C++)fatal error: No such …missing separator — Make: Makefile:5: *** missing separator. Stop. (spaces instead of a tab) (C/C++)missing separatorNo rule to make target — Make: *** No rule to make target 'foo.c', needed by 'foo.o'. Stop. (C/C++)No rule to make targetnot a member of std — C++: error: 'optional' in namespace 'std' does not name a template type — wrong -std standard (C/C++)not a member of stdredefinition of — C++: error: redefinition of 'class X' / multiple definition — missing include guard (C/C++)redefinition ofundefined reference to — C/C++: undefined reference to `function' — collect2: error: ld returned 1 exit status (C/C++)undefined reference toundefined reference to main — C/C++: undefined reference to `main' — (.text+0x20) in crt1.o (C/C++)undefined reference t…Could not…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.