ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

unresolved external with catkin, compilation with make succed [closed]

asked 2014-12-04 10:50:06 -0500

mennamatteo gravatar image

updated 2014-12-05 03:52:18 -0500

I am trying to compile a ros library under catkin. My library, ConversionPcl.cpp, use
pcl_ros::transformPointCloud(std::string, sensor_msgs::PointCloud2, sensor_msgs::PointCloud2, tf::TransformListener)

Compiling with catkin I have undefine reference to pcl_ros::transformPointCloud(). The CMakeFiles.txt look as follow:

project(path_planner)


find_package(catkin REQUIRED 
COMPONENTS   pcl_conversions dynamic_reconfigure  roscpp tf rospy geometry_msgs interactive_markers pcl_ros 
)

find_package(PCL 1.7 REQUIRED)

generate_dynamic_reconfigure_options(cfg/DynamicJoinPcl.cfg
                 cfg/NormalEstimationPcl.cfg    
                 cfg/TravAnal.cfg 
                 cfg/ClusterPcl.cfg)

 catkin_package(
     INCLUDE_DIRS include
     LIBRARIES ${PROJECT_NAME} 
     CATKIN_DEPENDS 
       pcl_conversions                      
       geometry_msgs 
       roscpp 
       rospy 
       tf 
       std_msgs
       interactive_markers
       pcl_ros

          DEPENDS system_lib 
      )

      include_directories(include ${catkin_INCLUDE_DIRS}  )

      add_library(normalestimation src/NormalEstimationPcl.cpp)
      add_library(dynamicjoinpcl src/DynamicJoinPcl.cpp)
      add_library(clusterpcl src/ClusterPcl.cpp)
      add_library(conversionpcl src/ConversionPcl.cpp)
      add_library(travanalpcl src/TravAnal.cpp)
      add_library(pathplanning src/PathPlanning.cpp)
      add_library(marker src/MarkerController.cpp)

       add_executable(mapping src/mapping.cpp)
      add_executable(traversability src/traversability.cpp)
       add_executable(pathPlanner src/pathPlanner.cpp)

       target_link_libraries(mapping dynamicjoinpcl  conversionpcl normalestimation  ${catkin_LIBRARIES} ${PCL_COMMON_LIBRARIES})
       target_link_libraries(traversability clusterpcl  conversionpcl travanalpcl  ${catkin_LIBRARIES}     ${PCL_COMMON_LIBRARIES})
    target_link_libraries(pathPlanner marker  pathplanning   ${catkin_LIBRARIES}  ${PCL_COMMON_LIBRARIES})

    add_dependencies(pathPlanner ${PROJECT_NAME}_gencfg)
    add_dependencies(mapping ${PROJECT_NAME}_gencfg)
    add_dependencies(traversability ${PROJECT_NAME}_gencfg)

    install(TARGETS pathPlanner
      ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
      LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
      RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
   )

     install(TARGETS traversability
     ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
     LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
     RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)


       install(FILES
   launch/test.launch
   launch/test.yaml   
    DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
 )

and I added the build and run dependencies in this way:

<build_depend>pcl_conversions</build_depend>  
<build_depend>pcl_ros</build_depend> 
<build_depend>libpcl-all-dev</build_depend>

<run_depend>pcl_conversions</run_depend>                            
<run_depend>pcl_ros</run_depend> 
<run_depend>libpcl-all</run_depend>

I tried to compile using make and it succed. The CMakeFIle is defined as follow:

CFLAGS=-fPIC -I../include $(shell pkg-config --cflags pcl_conversions)
CXXFLAGS=$(CFLAGS)
LDLIBS=-lstdc++ $(shell pkg-config --libs pcl_conversions)

libpclconversions.so: ConversionPcl.o
$(CC) $(LDLIBS) -shared $? -o $@

clean:
rm -f *.o libpclconversions.so

Is it a catkin bug or I am doing something wrong???

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by ahendrix
close date 2014-12-05 14:27:28.309008

Comments

This is a duplicate of http://answers.ros.org/question/19846... . PLEASE do not ask duplicate questions.

ahendrix gravatar image ahendrix  ( 2014-12-05 14:27:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-12-04 11:14:43 -0500

ahendrix gravatar image

find_package(PCL 1.7 REQUIRED) will find the PCL libraries, but it doesn't automatically compile or link against them. Instead, it sets cmake variables with the appropriate flags for using PCL: ${PCL_INCLUDE_DIRS} and ${PCL_LIBRARIES}.

You have to explicitly link against PCL with target_link_libraries():

target_link_libraries(my_library ${PCL_LIBRARIES})

Similarly, the libraries that you find through catkin are collected in ${catkin_LIBRARIES}, and you should link against those as well:

target_link_libraries(my_library ${catkin_LIBRARIES})
edit flag offensive delete link more

Comments

I am already doing it. This are the linking:

target_link_libraries(mapping  conversionpcl  ${catkin_LIBRARIES} ${PCL_COMMON_LIBRARIES})

mapping is the executable that use the library conversionpcl

mennamatteo gravatar image mennamatteo  ( 2014-12-04 11:35:28 -0500 )edit

I'm confused; are you getting a linking error when building your library, or when building an executable which uses your library? Are you building both your executable and your library with catkin_make?

Please edit your question to include your full CMakeLists.txt

ahendrix gravatar image ahendrix  ( 2014-12-04 11:47:11 -0500 )edit

I have the error when I build an executable that uses my library. I am building both the executable and the library with catkin_make. I edit the original question adding the full CMakeLists.txt as you suggested.

mennamatteo gravatar image mennamatteo  ( 2014-12-05 03:58:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-12-04 10:50:06 -0500

Seen: 233 times

Last updated: Dec 05 '14