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

Catkin library in Rosbuild package

asked 2015-07-09 07:15:27 -0500

cschou gravatar image

updated 2015-07-10 03:48:19 -0500

Hi All,

UPDATE: I think I might have resolved the issue. I added the "find_package" and "target_link_library" to the rosbuild CMakeLists.txt

I'm in the process of migrating some of my packages from ROSBUILD to CATKIN. Unfortunately, I cannot migrate all of them at the moment. I have migrated a package that builds a library and now I cannot get the rosbuild package that depends on it to compile.

So, my question is: How do I include a library generated in a CATKIN package in a ROSBUILD package?

This is the CMakeList of the CATKIN package building a library:


cmake_minimum_required(VERSION 2.8.3)
project(catkin_library_package)

find_package(catkin REQUIRED COMPONENTS
  roscpp
)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

###################################
## catkin specific configuration ##
###################################
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES myCatkinLibrary
  CATKIN_DEPENDS
  roscpp
)

###########
## Build ##
###########

include_directories(
  ${catkin_INCLUDE_DIRS}
  include
)


add_library(myCatkinLibrary myCatkinLibrary.cpp)

target_link_libraries(myCatkinLibrary
                      ${catkin_LIBRARIES}
                      )

install(TARGETS myCatkinLibrary
        ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})


install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
        FILES_MATCHING PATTERN "*.hpp")

And the CMakeList of the Rosbuild package, which includes the library from the catkin package:


cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

SET(CMAKE_VERBOSE_MAKEFILE ON)

# The name of the project.
PROJECT(rosbuild_package)


rosbuild_find_ros_package(actionlib_msgs)
include(${actionlib_msgs_PACKAGE_PATH}/cmake/actionbuild.cmake)

find_package(catkin_library_package)
include_directories(${catkin_library_package_INCLUDE_DIRS})

genaction()

rosbuild_init()

set(LibraryList
    ${LibraryList}
   )

rosbuild_add_boost_directories()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_genmsg()

rosbuild_add_executable(rosbuild_node src/main.cpp)
target_link_libraries(rosbuild_node ${catkin_library_package_LIBRARIES})

The CatkinLibraryPackage contains (amongst other) /include/catkin_library_package/mylibrary.hpp, which I'm trying to include in a ROSBUILD package. The rosbuild_package contains /src/main.cpp which specifies in the top: #include "catkin_library_package/myLibrary.hpp" All names are substitutes.

The catkin package compiles fine, but when trying to compile the ROSBUILD package, it cannot find the mylibrary.hpp file (a header in the catkin package).

UPDATE: I've been trying to find the answer to the question before submitting the question here, but without luck. However, today I somehow came across this post. I added the find_package(CatkinLibraryPackage) and the target_link_libraries(rosbuild_node ${CatkinLibraryPackage_LIBRARIES}) to the CMakeList of the ROSBUILD package. This way, I was able to get the rosbuild package to compile.

Any inputs on whether this is the correct way is appreciated...

Thanks to all for your input!

Best regards Casper

edit retag flag offensive close merge delete

Comments

1

Everything seems fine in principle as you described it, but without any detailed information on what exactly you error messages, file layout, workspace layout and cmake files are it is impossible to figure out the problem.

dornhege gravatar image dornhege  ( 2015-07-09 09:38:16 -0500 )edit

As @dornhege says, this is a normal migration path. That does not make it simple, there are many details to handle: http://docs.ros.org/jade/api/catkin/h... .

joq gravatar image joq  ( 2015-07-09 14:37:58 -0500 )edit

I was hoping for a "quick" point to some obvious error I had made. Since not the case, I have now updated the question with some code. I have though found a solution in the mean while, but would of course will post the updated info as requested.

cschou gravatar image cschou  ( 2015-07-10 03:52:19 -0500 )edit

You might need to add the include directories too: CatkinLibraryPackage_INCLUDE_DIRS

Dirk Thomas gravatar image Dirk Thomas  ( 2015-07-10 12:50:00 -0500 )edit

I did that? It's right under the find_package(...), if this is what you refer to...But you are right, that was indeed needed (perhaps the most important part in order to find the headers in the include folder)

cschou gravatar image cschou  ( 2015-07-10 12:54:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-09 15:35:05 -0500

William gravatar image

If the issue is that it cannot find the mylibrary.hpp file then you've probably not installed the header from the catkin package. This is typically how you'd install the headers in catkin:

## Install project namespaced headers
install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.h"
  PATTERN ".svn" EXCLUDE)

Note that the above assumes a structure for your headers as <package directory>/include/<package name>/mylibrary.hpp.

edit flag offensive delete link more

Comments

I do have the above in my CMakeList of the Catkin package. However, is there anyway I can check if the header gets installed correctly?

cschou gravatar image cschou  ( 2015-07-10 01:01:47 -0500 )edit

I actually found a way to resolve the error, thanks to another post with a reply by you. For that, thank you ๐Ÿ˜€

cschou gravatar image cschou  ( 2015-07-10 03:50:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-09 07:15:27 -0500

Seen: 364 times

Last updated: Jul 10 '15