Reputation: 179
I am developing a c++ library B
which depends on another library A
.
The two libray both use protobuf to define message objects
For example,
// A.proto in library `A
package libA;
message ObjA {...}
And I want to use it in library B
// B.proto in library `B`
import A.proto // ??? is this right ???
message ObjB {
ObjA obj_a=1;
}
If I just copy A.proto into current library B
, duplicated classes for ObjA
will be created.
But if I didn't copy A.proto, how could I use message ObjA
in message ObjB
?
Upvotes: 1
Views: 1170
Reputation: 1580
What you can do is add the search path for protoc to the directory in which A.proto is located:
protoc -I=DIR_WITH_A B.proto
Also you can write the relative dir with the import statement in B.proto:
// B.proto in library `B`
import "SOME_DIR/A.proto";
message ObjB {
ObjA obj_a=1;
}
Upvotes: 1