Hello,

I'm trying to use protobuf in a project with multiple libraries, where different libraries define message types that can ultimately be combined. Thus I have different proto files, in different directories.

I understand I can use the "package" directive to let protoc generate appropriate namespaces in the generated C++ code.

However, I'm surprised that the relative path location (as indicated with the "import" directive) also influences the generated code. Notably, I'm using `import "TSMarkers/Frame.proto"`, which causes a function call "protobuf_TSMarkers_2fFrame_2eproto::InitDefaultsFrame();" to be generated, though that function doesn't exist.

Is this behaviour documented somewhere ? I was thinking of the "import" statement as something akin to C++ includes, where the path has no bearing on how the (preprocessed) code is seen by the compiler, i.e. I'm free to move C++ headers around, as long as I adjust the include search paths. But with protoc, the (relative) location matters to the code.

Are there any guidelines on how to use protobuf (and protoc in particular) in an environment with multiple ("distributed") proto files ?

(The CMake docs in https://cmake.org/cmake/help/v3.9/module/FindProtobuf.html mention

"The |protobuf_generate_cpp| and |protobuf_generate_python| functions and |add_executable()| <https://cmake.org/cmake/help/v3.9/command/add_executable.html#command:add_executable> or |add_library()| <https://cmake.org/cmake/help/v3.9/command/add_library.html#command:add_library> calls only work properly within the same directory.", which is rather cryptic, but may hint things not working in non-local situations like mine, though given that this is part of the CMake docs, I wouldn't expect this to have any bearing on protobuf itself.)


Thanks,


Stefan

--

      ...ich hab' noch einen Koffer in Berlin...
--
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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to