无法找到 "Protobuf" 提供的具有以下任何名称的包配置文件:ProtobufConfig.cmake protobuf-config.cmake

Could not find a package configuration file provided by "Protobuf" with any of the following names: ProtobufConfig.cmake protobuf-config.cmake

正在尝试为 GRPC 编译 quick start 示例。

它产生这些错误:

CMake Error at /home/priya/grpc/examples/cpp/cmake/common.cmake:101 (find_package):
  Could not find a package configuration file provided by "Protobuf" with any
  of the following names:

    ProtobufConfig.cmake
    protobuf-config.cmake

  Add the installation prefix of "Protobuf" to CMAKE_PREFIX_PATH or set
  "Protobuf_DIR" to a directory containing one of the above files.  If
  "Protobuf" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:24 (include)

我已经在其他类似问题上尝试了所有建议的解决方案,但无济于事。这些是对我不起作用的解决方案:

  1. find_package(protobuf CONFIG REQUIRED) 改为大写 find_package(Protobuf REQUIRED)
  2. 正在安装 pkg-config
  3. 这个thread

我找不到任何其他解决方案。任何帮助将不胜感激。

我猜这可能是由于 gRPC 存储库中缺少子模块引起的。你会在构建之前获得子模块吗?你可以 运行 git clone --recurse-submodules -b v1.38.0 https://github.com/grpc/grpc 作为例子。

所以问题是我是 bash 脚本的新手。我已经将 quick start 中的说明复制并粘贴到 bash 脚本中,这样我们就可以顺利地将 gRPC 存储库集成到我们的存储库中,而无需每次都手动构建。

此问题是由于错误地调用脚本引起的,这意味着安装目录的环境变量从未正确设置并且一直为空值。您必须在调用文件之前放置源代码,例如 source ./grpcSetup.sh。请阅读其他 Whosebug question 以更清楚地解释问题。