Jak opravit CMake: The imported target "gRPC::grpc_cpp_plugin" references the file

Problém

Při pokusu o build C++ projektu, který závisí na gRPC, se můžete setkat s následující chybou:

cmake-grpc-cpp-plugin-error.txt
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/grpc/gRPCTargets.cmake:194 (message):
  The imported target "gRPC::grpc_cpp_plugin" references the file

     "/usr/bin/grpc_cpp_plugin"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/x86_64-linux-gnu/cmake/grpc/gRPCTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/grpc/gRPCConfig.cmake:25 (include)
  CMakeLists.txt:37 (find_package)

Řešení

Je potřeba nainstalovat protobuf-compiler-grpc pro získání spustitelného souboru grpc_cpp_plugin. Můžete to udělat pomocí následujícího příkazu:

install-protobuf-compiler-grpc.sh
sudo apt -y install protobuf-compiler-grpc

Podívejte se na podobné články podle kategorie: C/C++