gazebo ros plugin make error: Undefined symbols for architecture x86_64
gazebo ros plugin make error: Undefined symbols for architecture x86_64
我是 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' return 以下输出:
[ 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
有人可以帮助我吗?
谢谢,
彼得罗
尝试用 GAZEBO_LIBRARIES 替换 target_link_libraries: GAZEBO_libraries。
我是 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' return 以下输出:
[ 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
有人可以帮助我吗?
谢谢,
彼得罗
尝试用 GAZEBO_LIBRARIES 替换 target_link_libraries: GAZEBO_libraries。