Hello, everyone, I am a farmer, not a wheel will only copy and paste the code porter, here will record some programming, record the pit stepped on, let life leave a trace, if you feel some help, welcome to pay attention to, thank you for sharing!

Today in to do a little test Grpc, introduced the “Google/protobuf/timestamp. The proto type, timestamp used at the time of the generated code to the following error:

google/protobuf/timestamp.proto: File not found.

message/message.proto:5:1: Import “google/protobuf/timestamp.proto” was not found or had errors.

message/message.proto:21:5: “google.protobuf.Timestamp” is not defined.

I don’t understand why, and then Google, all kinds of weird answers. I didn’t find the answer. Maybe I was looking for the answer in the wrong position.

Think about it later. Use the best reload method.

A new protoc was downloaded from the official package.

After unpacking the file, I found that there are two directories and a file, one is bin and readme. TXT, and another is include, which was not included in the installation. Click readme. TXT subconsciously, surprise.

Protocol Buffers - Google's data interchange format Copyright 2008 Google Inc. https://developers.google.com/protocol-buffers/ This package contains a precompiled binary version of the protocol buffer compiler (protoc). This binary is intended for users who want to use Protocol Buffers in languages other than C++ but do not want to compile protoc themselves. To install, simply place this binary somewhere in your PATH. If you intend to use the included well known types then don't forget to
copy the contents of the 'include' directory somewhere as well, for example
into '/usr/local/include/'.

Please refer to our official github site for more installation instructions:
  https://github.com/protocolbuffers/protobuf
Copy the code

If you intend to use the included well known types then don’t forget to copy the contents of the ‘include’ directory somewhere as well, for example into ‘/usr/local/include/’.

Try to include/Google moved to/usr/local/include/Google and then regenerate. No errors were reported and the code was generated correctly.

And then I thought about it.

Maybe when we use protoc to generate object code, these types are not base types, Google didn’t compile them into protoc at design time, Instead, he looks for.proto files in the /usr/local/include/folder he specified in the document.

Reviewing the cause of this problem, I feel that I am not careful enough to cause the problem, which is a waste of time. Fortunately, the problem was solved successfully,