Great! Thanks much > On Aug 28, 2020, at 10:14 PM, Nadav Samet <[email protected]> wrote: > > See the error level1/Level1.proto:7:5: "Level2Message" is not defined? The > package statement for level1 indicates protobufs.level1. For level2.proto the > package is protobufs.folderA.folderB. When level1 references the message in > level2 it needs to do so by its relative name or full name: > > protobufs.folderA.folderB.Level2Message level2Message = 1; > > Similar logic applies to how level0 references Level1Message. > > On Fri, Aug 28, 2020 at 10:07 PM Novice User <[email protected] > <mailto:[email protected]>> wrote: > I modified the Level1.proto , but still getting error. > > Level1.proto : > syntax = "proto3"; > > package protobufs.level1; > import "level1/level2/Level2.proto"; > > message Level1Message { > Level2Message level2Message = 1; > } > > > $ protoc -I=./ --python_out=. *.proto > level1/Level1.proto:7:5: "Level2Message" is not defined. > Level0.proto:4:1: Import "level1/Level1.proto" was not found or had errors. > Level0.proto:7:3: "Level1Message" is not defined. > > (Running it from directory which has Level0.proto) > > >> On Aug 28, 2020, at 9:59 PM, Nadav Samet <[email protected] >> <mailto:[email protected]>> wrote: >> >> The imports in proto files are relative to the search path (what you provide >> by -I), not to the files. You either need to the Level2 directory under the >> protobuf directory, or change the import in Level1.proto to import >> "level1/level2/Level2.proto" >> >> On Fri, Aug 28, 2020 at 9:54 PM Novice User <[email protected] >> <mailto:[email protected]>> wrote: >> I've nested proto (proto3) files [ Level0.proto depends on Level1.proto >> which in turn depend on Level2.proto] with the below tree structure : >> >> <xT5gv.png> >> >> >> Level0.proto >> >> syntax = "proto3"; >> >> package protobufs; >> import "level1/Level1.proto"; >> >> message Level0Message { >> Level1Message level1message = 1; >> } >> Level1.proto >> >> syntax = "proto3"; >> >> package protobufs.folderA; >> import "level2/Level2.proto"; >> >> message Level1Message { >> Level2Message level2Message = 1; >> } >> Level2.proto >> >> syntax = "proto3"; >> >> package protobufs.folderA.folderB; >> >> message Level2Message { >> string innerMost = 1; >> } >> Compilation fails : >> >> >> $ protoc -I=./ --python_out=. *.proto >> level2/Level2.proto: File not found. >> level1/Level1.proto:4:1: Import "level2/Level2.proto" was not found or had >> errors. >> level1/Level1.proto:7:5: "Level2Message" is not defined. >> Level0.proto:4:1: Import "level1/Level1.proto" was not found or had errors. >> Level0.proto:7:3: "Level1Message" is not defined. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <mailto:[email protected]>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/protobuf/81E01306-D492-4B20-903C-E1943FCD86AA%40gmail.com >> >> <https://groups.google.com/d/msgid/protobuf/81E01306-D492-4B20-903C-E1943FCD86AA%40gmail.com?utm_medium=email&utm_source=footer>. >> >> >> -- >> -Nadav > > > > -- > -Nadav
-- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/D9A5AB65-C985-4549-9500-D9DB41F93500%40gmail.com.
