Import the "google/protobuf/empty.proto" and "google/protobuf/any.proto
lifeng68 opened this issue · comments
My .proto file import the "google/protobuf/empty.proto" and "google/protobuf/any.proto", like this:
syntax = "proto3";
import "google/protobuf/empty.proto";
import "google/protobuf/any.proto";
I use "make lcrd.grpc-c.c" generated file,when I use "make" to build the code ,I find the google/protobuf/empty.proto.h can not find.
root@docker-RH2288H-V3:/home/lifeng/gRPC_c/grpc-c/build/lcrd# make lcrd.grpc-c.c
protoc -I ../../lcrd --grpc-c_out=. --plugin=protoc-gen-grpc-c=../compiler/protoc-gen-grpc-c ../../lcrd/lcrd.proto
root@docker-RH2288H-V3:/home/lifeng/gRPC_c/grpc-c/build/lcrd# make
gcc -DHAVE_CONFIG_H -I. -I../../lcrd -I.. -I. -I../../lcrd/../lib/h/ -I../../lcrd/../third_party/protobuf-c -I../../lcrd/../third_party/grpc/include -g -O2 -MT lcrd_client.o -MD -MP -MF .deps/lcrd_client.Tpo -c -o lcrd_client.o ../../lcrd/lcrd_client.c
In file included from ../../lcrd/lcrd_client.c:8:0:
**./lcrd.grpc-c.h:23:41: fatal error: google/protobuf/empty.proto.h: No such file or directory**
compilation terminated.
Makefile:447: recipe for target 'lcrd_client.o' failed
make: *** [lcrd_client.o] Error 1
@lifeng68 Do you have libprotobuf-dev installed?
I installed the libprotobuf-dev,my "/usr/local/include/google/protobuf" has these files ,but not have the empty.proto.h and any.proto.h
root@docker-RH2288H-V3:/usr/local/include/google/protobuf# ls
any.h descriptor_database.h empty.proto has_bits.h map_type_handler.h source_context.pb.h type.pb.h wrappers.proto
any.pb.h descriptor.h extension_set.h io message.h source_context.proto type.proto
any.proto descriptor.pb.h field_mask.pb.h map_entry.h message_lite.h struct.pb.h unknown_field_set.h
api.pb.h descriptor.proto field_mask.proto map_entry_lite.h metadata.h struct.proto util
api.proto duration.pb.h generated_enum_reflection.h map_field.h reflection.h stubs wire_format.h
arena.h duration.proto generated_enum_util.h map_field_inl.h reflection_ops.h text_format.h wire_format_lite.h
arenastring.h dynamic_message.h generated_message_reflection.h map_field_lite.h repeated_field.h timestamp.pb.h wire_format_lite_inl.h
compiler empty.pb.h generated_message_util.h map.h service.h timestamp.proto wrappers.pb.h
@ajhai Is it a bug in grpc-c that the generated file should not include google/protobuf/empty.proto.h
but the other name?
@hqhq Yes. This is a bug in grpc-c compiler code. It should have generated empty.pb.h instead of empty.proto.h. Possibly coming from protobuf-c. Will take a look and fix this.
I have hit this too (IIRC file was generated as foo.pb-c.h
but the #include
wanted foo.proto.h
). However, I am working in a project that also uses C++ gRPC bindings (which would generate a foo.pb.h
file) so beware of name collisions. foo.pb-c.h
might be the best to standardize on?
99797eb should fix this issue. Generated code will include google/protobuf/empty.grpc-c.h instead of google/protobuf/empty.proto.h. You still have to compile empty.proto separately though and make it available in google/protobuf from your objs.