gazebo ros plugin make error:体系结构x86_64的未定义符号

时间:2016-06-07 08:24:18

标签: c++ makefile ros dylib

我是ROS和Gazebo编程的新手。我正在尝试为我安装在机器人模型上的激光器创建一个控件插件。

我在MAC OS X 10.11.5上使用ROS indigo和gazebo 7.0

当我尝试使用标准'cmake'和'make'编译我的插件的.cc文件时出现问题。

在正式教程(http://gazebosim.org/tutorials/?tut=plugins_model)之后,我将CMakeLists.txt写成:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

find_package(roscpp REQUIRED)
find_package(std_msgs REQUIRED)
include_directories(${roscpp_INCLUDE_DIRS})
include_directories(${std_msgs_INCLUDE_DIRS})

# Find Gazebo
find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")



# Build our plugin
add_library(velodyne_plugin SHARED velodyne_plugin.cc)
target_link_libraries(velodyne_plugin ${GAZEBO_libraries} ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${roscpp_LIBRARIES})

我认为问题可能源于图书馆的依赖。

'cmake'命令似乎运行良好,而'make'返回以下输出:

[ 50%] Linking CXX shared library libvelodyne_plugin.dylib
Undefined symbols for architecture x86_64:
  "sdf::Console::ColorMsg(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, int)", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
      bool sdf::Param::Get<double>(double&) const in velodyne_plugin.cc.o
  "sdf::Console::Instance()", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
      bool sdf::Param::Get<double>(double&) const in velodyne_plugin.cc.o
      sdf::Console::ConsoleStream& sdf::Console::ConsoleStream::operator<<<char [30]>(char const (&) [30]) in velodyne_plugin.cc.o
      sdf::Console::ConsoleStream& sdf::Console::ConsoleStream::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
      sdf::Console::ConsoleStream& sdf::Console::ConsoleStream::operator<<<char [3]>(char const (&) [3]) in velodyne_plugin.cc.o
      sdf::Console::ConsoleStream& sdf::Console::ConsoleStream::operator<<<char [29]>(char const (&) [29]) in velodyne_plugin.cc.o
      sdf::Console::ConsoleStream& sdf::Console::ConsoleStream::operator<<<char [15]>(char const (&) [15]) in velodyne_plugin.cc.o
      ...
  "sdf::Element::GetElement(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
  "sdf::Element::GetAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
  "sdf::Element::HasElementDescription(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
  "gazebo::event::Connection::Connection(gazebo::event::Event*, int)", referenced from:
      gazebo::event::EventT<void (gazebo::common::UpdateInfo const&)>::Connect(boost::function<void (gazebo::common::UpdateInfo const&)> const&) in velodyne_plugin.cc.o
  "gazebo::event::Connection::~Connection()", referenced from:
      void boost::checked_delete<gazebo::event::Connection>(gazebo::event::Connection*) in velodyne_plugin.cc.o
  "gazebo::event::Events::worldUpdateBegin", referenced from:
      boost::shared_ptr<gazebo::event::Connection> gazebo::event::Events::ConnectWorldUpdateBegin<boost::_bi::bind_t<void, boost::_mfi::mf0<void, gazebo::VelodynePlugin>, boost::_bi::list1<boost::_bi::value<gazebo::VelodynePlugin*> > > >(boost::_bi::bind_t<void, boost::_mfi::mf0<void, gazebo::VelodynePlugin>, boost::_bi::list1<boost::_bi::value<gazebo::VelodynePlugin*> > >) in velodyne_plugin.cc.o
  "gazebo::common::Time::Time(double)", referenced from:
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
  "gazebo::common::Time::Time()", referenced from:
      gazebo::VelodynePlugin::VelodynePlugin() in velodyne_plugin.cc.o
  "gazebo::common::Time::~Time()", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
      gazebo::VelodynePlugin::~VelodynePlugin() in velodyne_plugin.cc.o
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
  "gazebo::common::Time::operator=(gazebo::common::Time const&)", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
  "gazebo::common::Time::operator+=(gazebo::common::Time const&)", referenced from:
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
  "ignition::math::IndexException::IndexException()", referenced from:
      ignition::math::Vector3<double>::operator[](unsigned long) const in velodyne_plugin.cc.o
      ignition::math::Vector2<int>::operator[](unsigned long) const in velodyne_plugin.cc.o
      ignition::math::Vector2<double>::operator[](unsigned long) const in velodyne_plugin.cc.o
  "sdf::Element::HasElement(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
  "sdf::Element::GetElementImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
  "sdf::Element::GetElementDescription(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      double sdf::Element::Get<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in velodyne_plugin.cc.o
  "gazebo::common::Time::Double() const", referenced from:
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
  "gazebo::common::Time::operator-(gazebo::common::Time const&) const", referenced from:
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
  "gazebo::physics::Base::GetWorld() const", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
  "gazebo::physics::Model::GetJointCount() const", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
  "gazebo::physics::Model::GetJoints() const", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
  "gazebo::physics::World::GetSimTime() const", referenced from:
      gazebo::VelodynePlugin::Load(boost::shared_ptr<gazebo::physics::Model>, std::__1::shared_ptr<sdf::Element>) in velodyne_plugin.cc.o
      gazebo::VelodynePlugin::UpdateChild() in velodyne_plugin.cc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libvelodyne_plugin.dylib] Error 1
make[1]: *** [CMakeFiles/velodyne_plugin.dir/all] Error 2
make: *** [all] Error 2

有人可以帮助我吗?

谢谢,

彼得

1 个答案:

答案 0 :(得分:1)

尝试用GAZEBO_LIBRARIES替换target_link_libraries:GAZEBO_libraries。