'Where to set the path to the protoc to import standards Protocol Buffers
Where need I to set the path
to the protoc
to get import standards Protocol Buffers (protobuf), like empty.proto
and timestamp.proto
in Windows and Dart?
When the protoc
is ran:
protoc --dart_out=grpc:lib/src/protos/generated -Iprotos protos/organization.proto --plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc-gen-dart.bat
The following error is presented:
google/protobuf/empty.proto: File not found. organization.proto: Import "google/protobuf/empty.proto" was not found or had errors. organization.proto:14:27: "google.protobuf.Empty" is not defined.
In IntelliJ Settings
on Protobuf Support
plugin the path
is define where standard protos (*.proto) are:
Additionally this path
is define in IntelliJ on Project Structure
\ Global Libraries
:
The code organization.proto
that import google/protobuf/empty.proto
to use Empty
class :
syntax = "proto3";
package auge.protobuf;
import "google/protobuf/empty.proto";
service OrganizationService {
rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}
IntelliJ analyzer recognizes the import "google/protobuf/empty.proto"
and Empty
class on IDEA, but protoc
can not find.
The environment is:
- SO: Windows 7 x64
- protoc: libprotoc 3.6.1
- Dart: 2.2.0-edge
Solution 1:[1]
Say you have /some/path/to/google/protobuf/empty.proto
, you need to pass --proto_path=/some/path/to/
so protoc can locate it.
Solution 2:[2]
use two dot before protobuf folder path
<Protobuf Include="..\Proto\protobuf.proto" ProtoRoot="Proto" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Igor Gatis |
Solution 2 | xxxsenatorxxx |