Protobuf3: How to use the new timestamp proto type?

37,300 views
Skip to first unread message

Robin

unread,
Jun 11, 2015, 9:08:33 PM6/11/15
to prot...@googlegroups.com
Hi everyone,

I have installed protobuf3.0.0-alpha-3 on my machine and have the following proto file:

syntax = "proto3";

package my.great.package;

import "google/protobuf/timestamp.proto";

option java_outer_classname = "TimestampedThingMsg";

message TimestampedThing {
    
    string thing = 1;
    Timestamp date = 2;
    
}

However when I run "protoc protobuf/timestamped_thing.proto" I get the following two errors:

protobuf/timestamped_thing.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.

protobuf/timestamped_thing.proto:15:5: "Timestamp" is not defined.


How can I import the new Timestamp message type (source file: https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto) to use it in my own messages?

The only related example I could find in the docs was for the Any type where the import looks exactly like mine so not sure how to go about this. Docs link: https://developers.google.com/protocol-buffers/docs/proto3#any


Thanks!

肖锋

unread,
Jun 12, 2015, 2:41:18 AM6/12/15
to prot...@googlegroups.com


On Thursday, June 11, 2015 at 6:08:33 PM UTC-7, Robin wrote:
Hi everyone,

I have installed protobuf3.0.0-alpha-3 on my machine and have the following proto file:

syntax = "proto3";

package my.great.package;

import "google/protobuf/timestamp.proto";

option java_outer_classname = "TimestampedThingMsg";

message TimestampedThing {
    
    string thing = 1;
    Timestamp date = 2;
    
}

However when I run "protoc protobuf/timestamped_thing.proto" I get the following two errors:

protobuf/timestamped_thing.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.

protobuf/timestamped_thing.proto:15:5: "Timestamp" is not defined.

protoc should be able to find these types automatically if they are installed with protoc. Where did you install the protoc binary? Could you check whether you can find google/protobuf/timestamp.proto in your include path? These protos should be installed along with protobuf header files.

Robin

unread,
Jun 12, 2015, 8:34:32 AM6/12/15
to prot...@googlegroups.com
I installed protobuf with the following homebrew command on OS X 10.10.3: brew install protobuf --devel
The binary is symlinked to /us/local/bin and the includes are symlinked to /usr/local/include/google/protobuf/timestamp.proto (which is present as I confirmed).

Which include path do you mean, the protoc -IPATH? And should it be sufficient in my .proto file to just use Timestamp or should I use the full google.protobuf.Timestamp?

Nathaniel Weems

unread,
May 6, 2016, 8:00:26 PM5/6/16
to Protocol Buffers
Using the fully qualified path "google.protobuf.Timestamp" works.

Camilo Aguilar

unread,
Jun 14, 2016, 1:18:10 PM6/14/16
to Protocol Buffers
Importing the definitions AND using the fully qualified path of the type fixed it for me.  Thanks!

Camilo Aguilar

unread,
Jun 14, 2016, 1:18:10 PM6/14/16
to Protocol Buffers
I'm also  unable to use the Timestamp type, using the fully qualified path didn't seem to work for me. 


On Friday, May 6, 2016 at 8:00:26 PM UTC-4, Nathaniel Weems wrote:

Chad Beaulac

unread,
Jun 15, 2016, 12:19:56 PM6/15/16
to Protocol Buffers
A buildable solution is in my post here:
https://groups.google.com/d/msg/protobuf/ecxdP_mN8OI/3FxhjiDaAQAJ

Importing and fully qualified name worked for me.

Andrés Castaño

unread,
May 17, 2017, 8:08:52 AM5/17/17
to Protocol Buffers
Hello all, I had the same issue when generating protos that contain Timestamp in Debian.

I got it working following this instructions:


Please note my comment about creating a symlink instead of moving the binary.
Reply all
Reply to author
Forward
0 new messages