我在使用tf
库时遇到链接器问题。以下是我的callback
。如果没有callback
中的唯一行,则没有链接器错误。请在下面找到链接器错误本身。
void callback (const sensor_msgs::PointCloud2ConstPtr& input)
{
listener->waitForTransform("/world_base_link", (*input).header.frame_id, (*input).header.stamp, ros::Duration(5.0));
}
int main (int argc, char** argv)
{
ros::init(argc, argv, "subscriber");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/kinect2/depth/points", 1, callback);
ros::spin ();
}
链接错误:
Linking CXX executable range_image_border_extraction
CMakeFiles/range_image_border_extraction.dir/range_image_border_extraction.cpp.o: In function `callback(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&)':
range_image_border_extraction.cpp:(.text+0x18c): undefined reference to `tf::Transformer::waitForTransform(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::Time const&, ros::Duration const&, ros::Duration const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: ld returned 1 exit status
make[2]: *** [range_image_border_extraction] Error 1
make[1]: *** [CMakeFiles/range_image_border_extraction.dir/all] Error 2
make: *** [all] Error 2
的CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(range_image_border_extraction)
find_package(PCL 1.7 REQUIRED)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(range_image_border_extraction range_image_border_extraction.cpp)
target_link_libraries(range_image_border_extraction ${PCL_LIBRARIES})
target_link_libraries(range_image_border_extraction ${catkin_LIBRARIES})
package.xml中
<?xml version="1.0"?>
<package>
<name>ipa325_com_client</name>
<version>1.0.0</version>
<description>Simulation client side communication interface</description>
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>control_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>ipa325_msgs</build_depend>
<build_depend>ipa325_com_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>tf</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>control_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>ipa325_com_msgs</run_depend>
<run_depend>ipa325_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<export></export>
</package>
如何解决此链接器错误的任何想法?