I am trying to use Timestamp and have imported it in protobuf message -
import "google/protobuf/timestamp.proto";
message TriggerDataMsg {
google.protobuf.Timestamp start_time = 1;
google.protobuf.Timestamp end_time = 2;
google.protobuf.Timestamp next_fire_time = 3;
google.protobuf.Timestamp previous_fire_time = 4;
sint32 priority = 13;
}
When trying to compile with protoc compiler to generate Java classes, its failing with the below error -
[echo] compiling proto sources...
[exec] google/protobuf/timestamp.proto:35:8: Option "csharp_namespace" unknown.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:24:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:25:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:26:5: "google.protobuf.Timestamp" is not defined.
[exec] com/vmware/nsx/management/backup/model/trigger_data.proto:27:5: "google.protobuf.Timestamp" is not defined.
I am not sure why its checking for "csharp_namespace" even though I am generating Java classes. Any workaround which I can try to get rid of this error ?
If you want protoc to automatically import something, it needs to be in an /include folder next to your protoc binary.
If I remember correctly, protoc looks for includes relative to the protoc binary. So if protoc is in /usr/local/bin, then it will look in /usr/local/include.
This worked perfectly for me on Windows to solve:
Import "google/protobuf/wrappers.proto" was not found or had errors.