尽管构建成功,但 Eclipse Neon 构建错误

Eclipse Neon build errors despite successful build

我正在尝试使用 Eclipse 为涉及 Gazebo(一种流行的机器人模拟器)的项目进行开发。 Gazebo 提供了一个插件系统,允许与模拟器进行外部交互,并提供了一系列关于如何编写插件的教程。

成功遵循教程后,我尝试将代码迁移到 Eclipse,使用 cmake -G "Eclipse CDT4 - Unix Makefiles" [buildpath] 生成一个 eclipse rpoject,然后将其导入我的 Eclipse 工作区。

一切都很顺利,但我 运行 遇到了一个有点奇怪的问题:

当我编译我的项目时,Eclipse 返回 "Member declaration not found" 错误,指的是 ModelPush::Load 函数签名中使用的 SDFormat 数据类型(参见下面的代码片段)。 SDFormat,顺便说一下,是一种机器人技术 XML,用于描述机器人的组装方式。

尽管出现此错误(应该不会生成任何内容),但无论如何都会生成生成的共享库。

我想我可以忍受,但我显然想解决这个问题,这似乎是 Eclipse 的内部问题/CDT...


澄清:

我试图确定为什么 Eclipse 在 model_push.cc 中的 Load() 函数签名上给我错误:"Member declaration not found"。有罪的一方是sdf::ElementPtr _sdf参数。 SDFormat 库或 Eclipse / CDT 查看它的方式有问题。这不是包含问题。而且,即使 Eclipse 给我错误,它仍然会构建 .so 文件。 运行 从命令行 make 也生成文件,但没有任何错误。

同样,我可以忍受,但我宁愿不。我只是不知道从哪里开始寻找解决方案,因为找到包含或 sdf 库文件不是问题。


这是 class 声明 (mode_push.hh):

#ifndef MODEL_PUSH_HH_
#define MODEL_PUSH_HH_

#include <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <stdio.h>
#include <sdf/sdf.hh>

namespace gazebo
{
class ModelPush : public ModelPlugin
{
    public:

        void Load (physics::ModelPtr _parent, sdf::ElementPtr _sdf);

        //Called by the world update start event
        void OnUpdate (const common::UpdateInfo & /*_info*/);

    //Pointer to the model
    private:
        physics::ModelPtr model;

    //Pointer to the update event connection
    private:
        event::ConnectionPtr updateConnection;
};
}

#endif /* MODEL_PUSH_HH_ */

这是实现文件(model_push.cc):


#include "model_push.hh"

namespace gazebo
{
void ModelPush::Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
//void ModelPush::Load (physics::ModelPtr _parent, sdf::ElementPtr /*sdf*/)
{
    //Store the pointer to the model
    this -> model = _parent;

    //Listen to the update event.  This event is broadcast every
    //simulation iteration.
    this -> updateConnection = event::Events::ConnectWorldUpdateBegin(
        boost::bind (&ModelPush::OnUpdate, this, _1));
}

//Called by the world update start event
void ModelPush::OnUpdate (const common::UpdateInfo & /*_info*/)
{
    //Apply a small linear velocity to the model.
    this -> model -> SetLinearVel (math::Vector3 (0.03, 0.0, 0.0));
}

//Register this plugin with the simulator
//GZ_REGISTER_MODEL_PLUGIN(ModelPush)
}

我一直在努力解决这个确切的问题。我找到了一个可行的解决方案,但我仍然认为它不是理想的。我没有使用 cmake(或 catkin_make)生成 eclipse 项目,而是使用 CDT 项目生成器生成它。这是我在 Eclipse 2018-09 中使用的过程。

创建一个新的 C/C++ C++ 托管构建类型的项目(使用 CDT 的托管构建系统构建的 C++ 项目。)

项目名称:ROSWorkspace 位置:/home/username/eclipse-workspace/ROSWorkspace 项目类型:Makefile项目/空项目 工具链:Linux GCC

完成。

右键单击项目和 select 属性。

C/C++ 构建/构建器设置: 取消选中 "Use default build command" 构建命令:catkin_make 构建目录:${workspace_loc:/../catkin_ws}/

C/C++ 常规/路径和符号/包含选项卡 添加 /usr/include/gazebo-8 添加 /usr/include/sdformat-5.3

C/C++ 常规/预处理器包含/提供程序选项卡 CDT GCC 内置编译器设置/获取编译器规范的命令:${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=c++11

点击确定,然后从下拉菜单中选择: 项目/C/C++索引/刷新所有文件

理想情况下,我会花时间深入研究如何让预处理器正确处理生成的项目,但我现在没有时间。希望对您有所帮助。