protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.83k stars 15.52k forks source link

Import "google/protobuf/timestamp.proto" was not found or had errors #19361

Closed KKevinTso closed 3 days ago

KKevinTso commented 3 days ago

What version of protobuf and what language are you using? Version: main/

Language: C++ What operating system (Linux, Windows, ...) and version? Ubuntu 22.04

What runtime / compiler are you using (e.g., python version or gcc version) gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

What did you do? Steps to reproduce the behavior:

  1. git clone https://github.com/protocolbuffers/protobuf.git (Success)
  2. cd protobuf (Success)
  3. git submodule update --init --recursive (Success)
  4. bazel build :protoc :protobuf (Success)
  5. cp bazel-bin/protoc /usr/local/bin (Success)
  6. protoc --experimental_allow_proto3_optional --cpp_out=. mv_planning_output_info.proto (success)
  7. protoc --experimental_allow_proto3_optional --cpp_out=. CompressedVideo.proto (Failure)

What did you expect to see Generate CompressedVideo.pb.cc and CompressedVideo.pb.h。 What did you see instead? google/protobuf/timestamp.proto: File not found. CompressedVideo.proto:5:1: Import "google/protobuf/timestamp.proto" was not found or had errors. CompressedVideo.proto:12:3: "google.protobuf.Timestamp" is not defined. Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment CompressedVideo.proto is as below: // Generated by https://github.com/foxglove/schemas

syntax = "proto3";

import "google/protobuf/timestamp.proto";

package foxglove;

// A single frame of a compressed video bitstream message CompressedVideo { // Timestamp of video frame google.protobuf.Timestamp timestamp = 1;

// Frame of reference for the video. // // The origin of the frame is the optical center of the camera. +x points to the right in the video, +y points down, and +z points into the plane of the video. string frame_id = 2;

// Compressed video frame data. // // For packet-based video codecs this data must begin and end on packet boundaries (no partial packets), and must contain enough video packets to decode exactly one image (either a keyframe or delta frame). Note: Foxglove does not support video streams that include B frames because they require lookahead. bytes data = 3;

// Video format. // // Supported values: h264 (Annex B formatted data only) string format = 4; }

acozzette commented 3 days ago

When you invoke protoc you will need to pass the -I flag to tell it where to look for imports. So in this case if timestamp.proto is at $PROTOBUF/src/google/protobuf/timestamp.proto then you will want to pass -I$PROTOBUF/src.