Search code examples
cmakeprotocol-buffersgrpc

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


Trying to compile the quick start example for GRPC.

It produces these errors:

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)

I have tried all the proposed solutions for this on other similar questions but to no avail. These are the solutions that did not work for me:

  1. Changing find_package(protobuf CONFIG REQUIRED) to an uppercase find_package(Protobuf REQUIRED)
  2. Installing pkg-config
  3. This thread

I could not find any other solutions. Any help would be greatly appreciated.


Solution

  • So the problem is I am new with bash scripts. I had copied and pasted the instructions in quick start into a bash script so that we could integrate the gRPC repository into our repo smoothly without having to build manually each time.

    This problem was caused by incorrectly calling the script, which meant the environment variable for the install directory was never getting set correctly and was remaining an empty value. You must put source before calling the file, e.g source ./grpcSetup.sh. Please read this other stackoverflow question that explains the problem more clearly.