0

I tried to compile the new v1alpha2 of the grpc Google Assistant SDK.

For that I ran make (with cpp language output) inside the Google Assistant git repository, which generated my *.pb.cc and *.ob.h files. Then I tried to compile the /google/api, /google/type *.pb.cc files into .o files, that I can link into my basic project. (the embedded_assistant.proto has two import statements: import "google/api/annotations.proto"; import "google/type/latlng.proto";).

I also tried to compile it with /google/protobuf and /google/rpc.

It is automated by a makefile, and at this command I get the following error:

make generated command:
g++ -c -I/usr/local/include -pthread -I./googleapis/gens -I./grpc  -std=c++11 googleapis/gens/google/api/auth.pb.cc -o googleapis/gens/google/api/auth.pb.o

output:
googleapis/gens/google/api/auth.pb.cc:552:23: error: cannot cast '::google::protobuf::RepeatedPtrField< ::google::api::AuthenticationRule>' to its private base class
    'google::protobuf::internal::RepeatedPtrFieldBase'
rules_.InternalSwap(&other->rules_);
                    ^
/usr/local/include/google/protobuf/repeated_field.h:776:41: note: declared private here
class RepeatedPtrField PROTOBUF_FINAL : private internal::RepeatedPtrFieldBase {
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
googleapis/gens/google/api/auth.pb.cc:553:27: error: cannot cast '::google::protobuf::RepeatedPtrField< ::google::api::AuthProvider>' to its private base class
    'google::protobuf::internal::RepeatedPtrFieldBase'
providers_.InternalSwap(&other->providers_);
                        ^
/usr/local/include/google/protobuf/repeated_field.h:776:41: note: declared private here
class RepeatedPtrField PROTOBUF_FINAL : private internal::RepeatedPtrFieldBase {
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
googleapis/gens/google/api/auth.pb.cc:936:30: error: cannot cast '::google::protobuf::RepeatedPtrField< ::google::api::AuthRequirement>' to its private base class
    'google::protobuf::internal::RepeatedPtrFieldBase'
requirements_.InternalSwap(&other->requirements_);
                            ^
/usr/local/include/google/protobuf/repeated_field.h:776:41: note: declared private here
class RepeatedPtrField PROTOBUF_FINAL : private internal::RepeatedPtrFieldBase {
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
make: *** [googleapis/gens/google/api/auth.pb.o] Error 1

thanks for any help

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
mxkybe
  • 11
  • 1
  • 2
  • I hit this. Caused by version mixing gRPC and protobufs. Always use the same version of protobufs referenced by the gRPC branch you're building. – fionbio Jan 25 '18 at 15:41

1 Answers1

-1

I setup everything completly new, now it works. I think maybe some include pathes were wrong. (but i don't really know, why it works now)

  1. checkout https://github.com/googleapis/googleapis
  2. cd into googleapis and checkout submodules with git submodule update --init
  3. run make LANGUAGE=cpp
  4. compile alle the *.pb.cc files in subdirectorys googleapis/gens/google/api and googleapis/gens/google/type and googleapis/gens/google/assistant/embedded/v1alpha2
  5. put them together into an archive
  6. link that archive together with grpc and protobuf librarys and some sample code into an executable. protobuf and grpc need to be installed, like here in step 3: c++ v1alpha1 assistant sdk example

i put this dirty makefile together. not really nice, but does the trick.

GOOGLEAPIS_GENS_PATH = ./googleapis/gens

API_CCS = $(shell find ./googleapis/gens/google/api -name '*.pb.cc')

TYPE_CCS = $(shell find ./googleapis/gens/google/type -name '*.pb.cc')

ASSISTANT_CCS = $(shell find ./googleapis/gens/google/assistant/embedded/v1alpha2 -name '*.pb.cc')

CC = g++

FLAGS += -I$(GOOGLEAPIS_GENS_PATH)
FLAGS += -std=c++11

SRC = $(API_CCS) $(TYPE_CCS) $(ASSISTANT_CCS)

OBJ = $(SRC:%.cc=%.o)

PROG_FLAGS = $(FLAGS)
PROG_FLAGS += `pkg-config --libs grpc++ grpc`
PROG_FLAGS += `pkg-config --cflags --libs protobuf`
PROG_FLAGS += -I./googleapis/gens/google/assistant/embedded/v1alpha2

PROG_SRC = main.cpp
PROG_OBJ = $(PROG_SRC:%.cpp=%.o)

all: prog

prog: assistant_api.ar $(PROG_SRC)
    $(CC) $(PROG_FLAGS) $(PROG_SRC) assistant_api.ar -o prog

assistant_api.ar: $(OBJ)
    ar r $@ $?

$(OBJ): $(SRC)
    $(CC) -c $(FLAGS) $*.cc -o $*.o

clean:
    rm -rf *.o assistant_api.ar $(OBJ)
mxkybe
  • 11
  • 1
  • 2