FreddyMro
FreddyMro

Reputation: 76

CMake: Error linking GMP and MPFR on Ubuntu

I'm running Ubuntu (24.04) and am trying to compile a C++ project using the GMP and MPFR library. I have the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.29)
project(find_gmp)

set(CMAKE_CXX_STANDARD 20)

find_package(GMP REQUIRED)
find_package(MPFR REQUIRED)

add_executable(find_gmp main.cpp)

Unfortunately, when trying to build the project, I get the following error:

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "FindGMP.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "GMP", but
  CMake did not find one.

  Could not find a package configuration file provided by "GMP" with any of
  the following names:

    GMPConfig.cmake
    gmp-config.cmake

  Add the installation prefix of "GMP" to CMAKE_PREFIX_PATH or set "GMP_DIR"
  to a directory containing one of the above files.  If "GMP" provides a
  separate development package or SDK, be sure it has been installed.

I have already installed libgmp-dev and libmpfr-dev but still, I get the error.

Does somebody know how I can properly set up my CMakeLists or which packages I need to install? Thanks!

Upvotes: 0

Views: 61

Answers (0)

Related Questions