我有一个库,基本上只是/usr/include/ignition/msgs1/ignition/msgs
中的一堆原型文件。我正在尝试制作使用ignition::msgs::Vector3d
和ignition::msgs::Quaternion
的自定义消息。
这是我的state.proto
syntax = "proto2";
package cdrone.messages;
import "quaternion.proto";
import "vector3d.proto";
message State
{
required int64 time = 1;
required Vector3d position = 2;
required Vector3d velocity = 3;
required Quaternion attitude = 4;
required Vector3d angular_velocity = 5;
}
这是我用来编译protobufs的CMakeLists.txt:
include_directories(${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} "/usr/include/ignition/msgs1/ignition/msgs")
set(ProtoFiles
gamepad.proto
motor_power.proto
/usr/include/ignition/msgs1/ignition/msgs/vector3d.proto
/usr/include/ignition/msgs1/ignition/msgs/quaternion.proto
state.proto)
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
add_library(messages SHARED ${ProtoSources})
target_link_libraries(messages ${PROTOBUF_LIBRARY})
看起来它找到了vector3d.proto
和quaternion.proto
,但当它尝试在vector3d.proto
或quaternion.proto
内导入另一个原型时,却无法找到新的导入
$ make
[ 5%] Built target cpptoml-parser
[ 10%] Built target cpptoml-build
[ 15%] Built target cpptoml-conversions
[ 21%] Built target parse
[ 23%] Running C++ protocol buffer compiler on state.proto
ignition/msgs/header.proto: File not found.
quaternion.proto: Import "ignition/msgs/header.proto" was not found or had errors.
quaternion.proto:32:12: "Header" is not defined.
vector3d.proto: Import "ignition/msgs/header.proto" was not found or had errors.
vector3d.proto:32:12: "Header" is not defined.
state.proto: Import "quaternion.proto" was not found or had errors.
state.proto: Import "vector3d.proto" was not found or had errors.
state.proto:12:12: "Vector3d" is not defined.
state.proto:13:12: "Vector3d" is not defined.
state.proto:14:12: "Quaternion" is not defined.
state.proto:15:12: "Vector3d" is not defined.
src/common/messages/CMakeFiles/messages.dir/build.make:94: recipe for target 'src/common/messages/state.pb.cc' failed
make[2]: *** [src/common/messages/state.pb.cc] Error 1
CMakeFiles/Makefile2:413: recipe for target 'src/common/messages/CMakeFiles/messages.dir/all' failed
make[1]: *** [src/common/messages/CMakeFiles/messages.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2