如何修复 CMake:Could not find a package configuration file provided by "gRPC"

问题

在尝试构建依赖 gRPC 的 C++ 项目时,你可能会遇到以下错误:

cmake-grpc-not-found-error.txt
CMake Error at CMakeLists.txt:37 (find_package):
  Could not find a package configuration file provided by "gRPC" with any of
  the following names:

    gRPCConfig.cmake
    grpc-config.cmake

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

解决方案

你需要安装 libgrpc-dev 以获取 gRPC 所需的 CMake 配置文件。可以使用以下命令安装:

install-grpc-dev.sh
sudo apt -y install libgrpc-dev

Check out similar posts by category: C/C++