0

grpc Google Assistant SDKの新しいv1alpha2をコンパイルしようとしました。Google Assistant SDK「api/auth.pb.cc」でコンパイルエラーをキャストできません

Google Assistant gitリポジトリ内でmake(cpp言語出力)を実行しました。私の*.pb.cc*.ob.hというファイルが生成されました。それから私は/google/api/google/type*.pb.ccファイルを.oファイルにコンパイルしようとしました。それは私の基本プロジェクトにリンクすることができます。 (embedded_assistant.protoには2つのインポートステートメントがあります:import "google/api/annotations.proto"; import "google/type/latlng.proto";)。

また、/google/protobuf/google/rpcでコンパイルしようとしました。

それはmakefileによって自動化され、このコマンドでは、私は次のエラーを取得されています。任意の助け

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 

感謝をし、completly新しい、今それ

+0

私はこれを打つ。 gRPCとprotobufsのバージョンミックスによって発生します。ビルドしているgRPCブランチが参照しているものと同じバージョンのprotobufsを必ず使用してください。 – fionbio

答えて

-1

Iセットアップはすべてあなたに素敵な休日を望みます働く私は多分pathesが間違っていたことを含むと思う。 git submodule update --init

  • 実行make LANGUAGE=cpp
  • コンパイルとgoogleapisとチェックアウトのサブモジュールへの

    1. チェックアウトhttps://github.com/googleapis/googleapis
    2. CD(それが動作するようになりましなぜ私は本当に、知りません)ALLE subdirectorys googleapis/gens/google/api*.pb.ccファイルとgoogleapis/gens/google/typeおよびgoogleapis/gens/google/assistant/embedded/v1alpha2
    3. これらを一緒にアーカイブに入れます。
    4. は、grpcprotobufのライブラリといくつかのサンプルコードを一緒にアーカイブし、実行ファイルにリンクします。 protobufgrpcは、ここでステップ3のように、インストールする必要があります:c++ v1alpha1 assistant sdk example

    私は一緒にこの汚いメイクファイルを置きます。本当に素晴らしくはありませんが、そのトリックを行います。

    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 [email protected] $? 
    
    $(OBJ): $(SRC) 
        $(CC) -c $(FLAGS) $*.cc -o $*.o 
    
    clean: 
        rm -rf *.o assistant_api.ar $(OBJ) 
    
  • 関連する問題