tf2::fromMsg cause "Undefined reference"

asked 2017-07-29 19:35:27 -0500

Steven Wei gravatar image

updated 2017-07-30 15:34:35 -0500

Hi all,

I want to convert geometry_msgs::Point into tf2::Vector3 to do some computation. There has an API void tf2::fromMsg (const geometry_msgs::Point &in, tf2::Vector3 &out) to do so, but it causes undefined reference, below is the error when I build my package.

undefined reference to 'void tf2::fromMsg<geometry_msgs::Point_<std::allocator<void> >, tf2::Vector3>(geometry_msgs::Point_<std::allocator<void> > const&, tf2::Vector3&)'

collect2: error: ld returned 1 exit status

Below is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(clean_viz)

find_package(catkin REQUIRED COMPONENTS
    geometry_msgs
    roscpp
    std_msgs
    tf2_geometry_msgs
    tf2_ros
    visualization_msgs
)


catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS
    geometry_msgs
    roscpp
    std_msgs
    tf2_geometry_msgs
    tf2_ros
    visualization_msgs
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_executable(clean_viz src/clean_viz.cpp)

target_link_libraries(
  clean_viz
  ${catkin_LIBRARIES}

Anybody know how to solve it? Thanks in advance.

edit retag flag offensive close merge delete

Comments

Could you show your CMakelists.txt?

NEngelhard gravatar image NEngelhard  ( 2017-07-30 03:59:54 -0500 )edit

Are you including the header that defines that method in your source?

tfoote gravatar image tfoote  ( 2017-11-26 16:10:31 -0500 )edit