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

Adding external dependency (FLANN) to catkin package

asked 2016-01-19 16:29:44 -0600

Ali250 gravatar image

updated 2016-01-19 16:30:16 -0600

I'm trying to add FLANN (Fast Library for Approximate Nearest Neighbors) as a system dependency to a catkin package. I installed FLANN from the source as instructed on the website and then setup my ROS package's CMakeList.txt as follows:

cmake_minimum_required(VERSION 2.8.3)
project(nao_whole_body_ik)

find_package(catkin REQUIRED COMPONENTS
    roscpp)

find_package( PkgConfig REQUIRED)
pkg_check_modules( flann REQUIRED flann )

catkin_package(
INCLUDE_DIRS include
    LIBRARIES nao_whole_body_ik
)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(test_node src/test1_node.cpp)
target_link_libraries(test_node ${catkin_LIBRARIES})

Then in my test1_node.cpp file I just have the test code given on their website, which consists of the following 2 include directives:

#include <flann/flann.hpp>
#include <flann/io/hdf5.h>

The first include statement works fine. The second one produces a long list of linking errors complaining about undefined references to various functions. I'm not very good at configuring the CMakeLists file, but I suspect that I need to add hdf5 as a system dependency as well, but I can't figure out how to add multiple system dependencies. Simply writing pkg_check_modules( flann REQUIRED flann hdf5 ) doesn't work.

I'm using Ubuntu 14.04 with ROS Indigo.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-01-20 11:07:15 -0600

Ali250 gravatar image

updated 2016-01-20 11:08:42 -0600

I was able to solve the problem by simply adding this line to CMakeLists.txt above find_package:

FIND_LIBRARY(HDF5_LIBRARY hdf5 /usr/local/hdf5/lib/)

and then after creating the executable:

target_link_libraries(test_node ${CATKIN_LIBRARIES} ${HDF5_LIBRARY}})

Also, it's better to install hdf5 by compiling the source code. Initially I tried doing it from the repository but it said that the library was already installed even though it wasn't.

edit flag offensive delete link more
0

answered 2016-08-02 14:01:22 -0600

AndyZe gravatar image

I had the same issue (twice). You don't need to install "libhdf5-dev" from source, sudo apt-get install libhdf5-dev works. In CMakeLists, add:

target_link_libraries(your_executable ${CATKIN_LIBRARIES} hdf5 hdf5_cpp hdf5_hl_cpp)

And in your cpp file:

#include "H5Cpp.h"
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-01-19 16:29:44 -0600

Seen: 2,071 times

Last updated: Aug 02 '16