exmpl-cmake-grpc: `protoc-gen-grpc: program not found or is not executable`
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
message(STATUS "Found gRPC C++ plugin at ${grpc_cpp_plugin_location}")
...
protobuf_generate(TARGET maid_proto LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cpp PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}")
yields the output:
-- Found gRPC C++ plugin at /usr/bin/grpc_cpp_plugin
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/src/maid/bin
[ 12%] Running grpc protocol buffer compiler on remote.proto
protoc-gen-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
make[2]: *** [protos/CMakeFiles/maid_proto.dir/build.make:90: protos/remote.grpc.pb.h] Error 1
make[1]: *** [CMakeFiles/Makefile2:141: protos/CMakeFiles/maid_proto.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
Why doesn’t this build? grpc_cpp_plugin is available in PATH, since it’s in /usr/bin.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (4 by maintainers)
I resolved this with
ln -s $(which grpc_cpp_plugin) /usr/bin/protoc-gen-grpc. Dumb workaround, but it works for now.I think this was caused by me using the system install of protobuf/grpc
Impressive debugging, @faaxm!
-DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIGworks perfectly, thanks very much for that tip!Of course, that would be great! You could even have a scheduled GitHub Action and clone the dependencies at
HEADeach time you run.If it’s ok with you, I’d take parts of your Dockerfile and turn it into a github workflow for this repo as an example build and to see if future grpc/protobuf/cmake releases break stuff.
Thanks so much for this repository, it’s extremely helpful!
This issue is reproducible even when installing protobuf from source, e.g. with this Dockerfile:
Strangely, when using a module provider build for gRPC instead, it’s working. I’m not sure whether that’s due to a slight difference in versions or something else. Here’s a corresponding Dockerfile:
You should not have to use
include(FindProtobuf). It looks like protobuf was not properly installed and is missing its cmake files. In that case, you are probably using the outdatedFindProtobuf.cmakethat is installed together with cmake, rather than theprotobuf-config.cmakethat comes with protobuf.Try installing protobuf yourself from source, via cmake, and see if that fixes it.
If you want to learn more about
*-config.cmakevsFind*.cmakehave a look at this article and its “Resources” section at the end: Installing a Config.cmake file