Robotics StackExchange | Archived questions

Using Gazebo Plugin with .h File Type

I tried compiling a Gazebo plugin that is a header file (with .h file extension), it says:

CMake Error: CMake can not determine linker language for target: gazebo_ros_moveit_planning_scene
CMake Error: Cannot determine link language for target "gazebo_ros_moveit_planning_scene".

The following is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")

add_library(gazebo_ros_moveit_planning_scene SHARED gazebo_ros_moveit_planning_scene.h)
target_link_libraries(gazebo_ros_moveit_planning_scene ${GAZEBO_LIBRARIES})

Any suggestions for a fix? P.s. I'm trying to use this plugin: https://github.com/jhu-lcsr-forks/gazebo_ros_pkgs/blob/hydro-devel/gazebo_plugins/include/gazebo_plugins/gazebo_ros_moveit_planning_scene.h#L50-L82

Asked by stan on 2018-03-14 17:10:54 UTC

Comments

Answers

CMake couldn't figure out what language your file was written in. I couldn't find the CMake documentation about how it guesses what language a file is written in, but this stackoverflow post has more info. You can tell CMake the language explicitly by setting a property on the library target.

Add this after the call to add_library

set_target_properties(gazebo_ros_moveit_planning_scene PROPERTIES LINKER_LANGUAGE CXX)

Side note, Is all the code for your gazebo plugin in gazebo_ros_moveit_planning_scene.h? Often code is divided into a header and source file. If all the code is in that file then it is more common to name it .cpp or .cc. The extension .h is usually given to C header files.

Asked by sloretz on 2018-03-14 20:21:53 UTC

Comments

Hi sloretz, thanks for the swift response. I am using the open-source code on github that I put the link at the bottom of my question. I am new to Gazebo and am not sure if all the code for the gazebo plugin is in that .h file. Could you please give me a few pointers? Thanks!

Asked by stan on 2018-03-14 21:43:17 UTC

There is a .cpp file with the same name in the src folder.

Asked by Raskkii on 2018-03-16 02:33:47 UTC