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)

Most upvoted comments

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=CONFIG works perfectly, thanks very much for that tip!

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.

Of course, that would be great! You could even have a scheduled GitHub Action and clone the dependencies at HEAD each 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!

Try installing protobuf yourself from source, via cmake, and see if that fixes it.

This issue is reproducible even when installing protobuf from source, e.g. with this Dockerfile:

FROM debian:bullseye-slim

RUN apt update && apt install -y build-essential autoconf libtool pkg-config git cmake libc-ares-dev libre2-dev libssl-dev zlib1g-dev curl

RUN mkdir -p /build/abseil-cpp && cd /build/abseil-cpp && \
    curl -sSL https://github.com/abseil/abseil-cpp/archive/refs/tags/20210324.2.tar.gz | tar -xzf - --strip=1 && \
    mkdir build && cd build && \
    cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTING=OFF \
    -DBUILD_SHARED_LIBS=yes && \
    make -j64 install && \
    ldconfig

RUN mkdir -p /build/protobuf && cd /build/protobuf && \
    curl -sSL https://github.com/google/protobuf/archive/v3.17.3.tar.gz | tar -xzf - --strip=1 && \
    mkdir build && cd build && \
    cmake ../cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=yes \
    -Dprotobuf_BUILD_TESTS=OFF && \
    make -j64 install && \
    ldconfig

RUN mkdir -p /build/grpc && cd /build/grpc && \
    curl -sSL https://github.com/grpc/grpc/archive/refs/tags/v1.39.0-pre1.tar.gz| tar -xzf - --strip=1 && \
    mkdir build && cd build && \
    cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DgRPC_INSTALL=ON \
    -DgRPC_BUILD_TESTS=OFF \
    -DgRPC_ABSL_PROVIDER=package \
    -DgRPC_CARES_PROVIDER=package \
    -DgRPC_PROTOBUF_PROVIDER=package \
    -DgRPC_RE2_PROVIDER=package \
    -DgRPC_SSL_PROVIDER=package \
    -DgRPC_ZLIB_PROVIDER=package && \
    make -j64 install && \
    ldconfig

RUN cd / && \
    git clone https://github.com/faaxm/exmpl-cmake-grpc.git && \
    cd exmpl-cmake-grpc && \
    mkdir build && cd build && \
    cmake .. && \
    make -j64

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:

FROM debian:bullseye-slim

RUN apt update && apt install -y build-essential autoconf libtool pkg-config git cmake libc-ares-dev libre2-dev libssl-dev zlib1g-dev curl

RUN git clone --recurse-submodules -b v1.39.0-pre1 https://github.com/grpc/grpc && \
    cd /grpc/third_party/abseil-cpp && \
    cmake . && \
    make -j64 install && \
    cd /grpc && mkdir build && cd build && \
    cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF .. && \
    make -j64 install && \
    ldconfig

RUN cd / && \
    git clone https://github.com/faaxm/exmpl-cmake-grpc.git && \
    cd exmpl-cmake-grpc && \
    mkdir build && cd build && \
    cmake .. && \
    make -j64

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 outdated FindProtobuf.cmake that is installed together with cmake, rather than the protobuf-config.cmake that 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.cmake vs Find*.cmake have a look at this article and its “Resources” section at the end: Installing a Config.cmake file