'Dependent proto buffer files produces a "descriptor_table_**_2eproto" has not been declared error
So, I am trying to compile a set of .proto files with the cmake function protobuf_generate_cpp, all of them in the same folder, and some dependent on others. The idea is to create a static library that let me use the messages in other projects.
Let's say I have the following structure in my project:
messages-lib/
|
+- company
| |
| +- messages
| |
| +- Header.proto // dependent on Robot.proto
| +- Robot.proto
| +- CMakeLists.txt
+- CMakeLists.txt
Header.proto imports Robot.proto with the following line: import "company/messages/Robot.proto" because the idea is to install the library, so any other user should import common messages like that.
However, when I compile the project by using the CMake function provided by Google protobuf_generate_cpp it produces the following error:
project/messages/Header.pb.cc:74:6: error: ‘::descriptor_table_company_2fmessages_2fRobot_2eproto’ has not been declared
What happend? Looking at the code generated by the CMake function, it seems that for Robot.pb.h, it defines a DescriptorTable with the follwing name: descriptor_table_Robot_2eproto but then it tries to use descriptor_table_company_2fmessages_2fRobot_2eproto in Header.pb.cc. Obviously it is not declared.
Another thing that might be important, is that I set Protobuf_IMPORT_DIRS in company/messages/CMakeLists.txt as the project directory (messages-lib), in order to be able to import the proto files as I am currently doing.
Is there a way to solve this issue? (Other than setting all the messages to LITE_RUNTIME optimization, which is not an option since I want to use reflection).
If anyone can help me would be great!
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
