GoogleCloudPlatform/cpp-samples

error while Generate googleapis gRPC source code

Closed this issue · 9 comments

afsxt commented

protoc --proto_path=.:/usr/local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin google/maps/routes/v1/route_service.proto
[libprotobuf FATAL /home/maybe/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name.
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): Unclosed variable name.
--grpc_out: protoc-gen-grpc: Plugin killed by signal 6.
Makefile:44: recipe for target 'google/maps/routes/v1/route_service.pb.cc' failed

grpc version: v1.27.3
protoc version: 3.11.2
ubuntu: 18.04

That seems like a bug in gRPC or Protobuf, have you reported the bug with them?

@tmatsuo do we have any examples in this repo that compile all the protos in googleapis? If so, we should clean that up.

Currently the speech sample generates google/maps/routes/v1/route_service.pb.cc with gRPC 1.26.

now is it solved?

now is it solved?

You mean "how"?

I think the original bug report was trying to use the grpc plugin distributed with gRPC v1.27.3, which for whatever reason was crashing. Downgrading to v1.26.x seems to work.

grpc version: v1.34 (latest)
protoc version: 3.13.0
ubuntu: 18.04

I am still getting this error while googleapis github repo
Any update???
step:

protoc --proto_path=.:/usr/local/.local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/.local/bin/grpc_cpp_plugin google/maps/routes/v1alpha/route_service.proto [libprotobuf FATAL /usr/local/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Unclosed variable name.

any help

grpc version: v1.34 (latest)
protoc version: 3.13.0
ubuntu: 18.04

I am still getting this error while googleapis github repo
Any update???

I just compiled a similar configuration successfully using the Dockerfile at the end of this comment. I suspect you picked a bad version of googleapis or you are missing some build step.

step:

I recommend that you do not use the top-level Makefile in that repository. It generates all the .pb.* files, but (a) you rarely need all of them, and (b) it does not produce any useful libraries that you can link against. It is better to use the libraries in https://github.com/googleapis/google-cloud-cpp If that repository does not generate the protos you need, let us know (file a bug in that repository) in many cases we can add the additional protos. If all fails, create your own Makefile with just the protos you need.

protoc --proto_path=.:/usr/local/.local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/.local/bin/grpc_cpp_plugin google/maps/routes/v1alpha/route_service.proto [libprotobuf FATAL /usr/local/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Unclosed variable name.

Is there a particular reason you need to compile that file? Can you just skip it, or better yet, compile what you need?

any help

See below.

FROM ubuntu:18.04

RUN apt-get update && \
    apt-get --no-install-recommends install -y apt-transport-https apt-utils \
        automake build-essential ccache cmake ca-certificates git gcc g++ \
        libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev m4 make \
        pkg-config tar wget zlib1g-dev

WORKDIR /var/tmp/build
RUN wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
    tar -xf 20200225.2.tar.gz && \
    cd abseil-cpp-20200225.2 && \
    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
    cmake \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_TESTING=OFF \
      -DBUILD_SHARED_LIBS=yes \
      -DCMAKE_CXX_STANDARD=11 \
      -H. -Bcmake-out && \
    cmake --build cmake-out -- -j $(nproc) && \
    cmake --build cmake-out --target install -- -j $(nproc) && \
    ldconfig

WORKDIR /var/tmp/build
RUN wget -q https://github.com/google/protobuf/archive/v3.13.0.tar.gz && \
    tar -xf v3.13.0.tar.gz && \
    cd protobuf-3.13.0/cmake && \
    cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_SHARED_LIBS=yes \
        -Dprotobuf_BUILD_TESTS=OFF \
        -H. -Bcmake-out && \
    cmake --build cmake-out -- -j $(nproc) && \
    cmake --build cmake-out --target install -- -j $(nproc) && \
    ldconfig

WORKDIR /var/tmp/build
RUN wget -q https://github.com/google/re2/archive/2020-11-01.tar.gz && \
    tar -xf 2020-11-01.tar.gz && \
    cd re2-2020-11-01 && \
    cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_SHARED_LIBS=yes \
	-DBUILD_TESTING=OFF \
        -H. -Bcmake-out && \
    cmake --build cmake-out -- -j $(nproc) && \
    cmake --build cmake-out --target install -- -j $(nproc) && \
    ldconfig

WORKDIR /var/tmp/build
RUN wget -q https://github.com/grpc/grpc/archive/v1.34.0.tar.gz && \
    tar -xf v1.34.0.tar.gz && \
    cd grpc-1.34.0 && \
    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_SSL_PROVIDER=package \
        -DgRPC_ZLIB_PROVIDER=package \
	-DgRPC_RE2_PROVIDER=package \
	-DgRPC_BUILD_CODEGEN=ON \
        -H. -Bcmake-out && \
    cmake --build cmake-out -- -j $(nproc) && \
    cmake --build cmake-out --target install -- -j $(nproc) && \
    ldconfig

WORKDIR /var/tmp/build/googleapis
RUN wget -q https://github.com/googleapis/googleapis/archive/c1a601690b7fdfc2ca7a070038546321102b5f0b.tar.gz && \
    tar -xf c1a601690b7fdfc2ca7a070038546321102b5f0b.tar.gz && \
    cd googleapis-c1a601690b7fdfc2ca7a070038546321102b5f0b && \
    env LANGUAGE=cpp make all

Thanks for reply @coryan

I just compiled a similar configuration successfully using the Dockerfile at the end of this comment. I suspect you picked a bad version of googleapis or you are missing some build step.

those steps from https://github.com/GoogleCloudPlatform/cpp-samples/blob/master/speech/api/README.md

I recommend that you do not use the top-level Makefile in that repository. It generates all the .pb.* files, but (a) you rarely need all of them, and (b) it does not produce any useful libraries that you can link against. It is better to use the libraries in https://github.com/googleapis/google-cloud-cpp If that repository does not generate the protos you need, let us know (file a bug in that repository) in many cases we can add the additional protos. If all fails, create your own Makefile with just the protos you need.

I want to achieve speech to text and text to speech in cpp using googleapis. (I am using grpc::GoogleDefaultCredentials())
yes, don,t need all .pb, this is helpfull. Thanks!

Thanks for docker commands

can u suggest anything else for speech to text and text to speech in cpp using GCP??

can u suggest anything else for speech to text and text to speech in cpp using GCP??

I am afraid using the raw gRPC files is the best I can recommend at this time.

This still appears to be an issue with protoc 3.14.0 and grpc 1.35.0 on Ubuntu 20.10
protoc --proto_path=.:/usr/local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin google/maps/routes/v1/route_service.proto [libprotobuf FATAL /home/steve/simcortex/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Unclosed variable name. --grpc_out: protoc-gen-grpc: Plugin killed by signal 6. make: *** [Makefile:45: google/maps/routes/v1/route_service.pb.cc] Error 1