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

how to link openni library through the "CMakeLists.txt" file

asked 2013-02-26 18:02:46 -0500

Robin Hu gravatar image

I have installed ROS groovy and openni library in the ARM chip. Now I want to use openni library fouction , but I do not know how to link openni library through the "CMakeLists.txt" file. I used "target_link_libraries(${PROJECT_NAME} OpenNI)",but it can not link openni founction.Who can tell me how to link openni and write cmake file?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-02-27 08:12:39 -0500

Giovanni Saponaro gravatar image

updated 2013-02-27 23:19:05 -0500

Assuming that ROS Groovy uses OpenNI v1.*, as I presume (don't have an installation handy), try something along these lines:

pkg_check_modules (LIBUSB REQUIRED libusb-1.0)
include_directories (${LIBUSB_INCLUDE_DIRS})
link_directories (${LIBUSB_LIBRARY_DIRS})

FIND_PATH(OPEN_NI_INCLUDE "XnOpenNI.h" "OpenNIConfig.h" HINTS "$ENV{OPEN_NI_INCLUDE}" "/usr/include/ni" "/usr/include/openni" "/opt/ros/groovy/include/openni_camera")
FIND_LIBRARY(OPEN_NI_LIBRARY NAMES OpenNI libOpenNI HINTS $ENV{OPEN_NI_LIB} "/usr/lib")
LINK_DIRECTORIES($ENV{OPEN_NI_LIB})
INCLUDE_DIRECTORIES(${OPEN_NI_INCLUDE})
LINK_LIBRARIES(${OPEN_NI_LIBRARY})
FIND_PATH(XN_NITE_INCLUDE "libXnVNite.so" HINTS "$ENV{XN_NITE_INSTALL_PATH}" "/usr/include/nite")
FIND_LIBRARY(XN_NITE_LIBRARY NAMES libXnVNite_1_5_2.so HINTS $ENV{XN_NITE_INSTALL_PATH} "/usr/lib")
LINK_DIRECTORIES($ENV{XN_NITE_LIB_INSTALL_PATH} "/usr/lib")
INCLUDE_DIRECTORIES(${XN_NITE_INCLUDE})
LINK_LIBRARIES(${XN_NITE_LIBRARY})

target_link_libraries (your_project_name ${SSE_FLAGS} ${OPEN_NI_LIBRARIES} ${XN_NITE_LIBRARIES})

If, instead, you want to use a manually installed copy of OpenNI 2.* (not in ROS yet), please see this discussion for a starting CMakeLists.txt which solves some problems but not all. Disclaimer: this is a shameless link to a question related to OpenNI, CMake but not to ROS that I myself posted on the OpenNI forums.

edit flag offensive delete link more
1

answered 2013-02-26 19:26:37 -0500

yoos gravatar image

Based on the CMakeLists.txt included in openni_tracker, try this:

include(FindPkgConfig)
pkg_check_modules(OPENNI libopenni)
target_link_libraries(${PROJECT_NAME} ${OPENNI_LIBRARIES})
edit flag offensive delete link more

Comments

I can confirm this works under Kubuntu 12.10, ros groovy.

Kourosh gravatar image Kourosh  ( 2013-04-01 02:46:56 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-02-26 18:02:46 -0500

Seen: 3,215 times

Last updated: Feb 27 '13