Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMAKE can't find OpenNI

I’ve been trying to run the “tutorial to get started” with the Kinect libraries (http://nicolas.burrus.name/index.php/Research/KinectUseNestk) but I stumbled across an error.

When I try the following line in the CLI:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

I get the following error:

CMake Error at D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHan
dleStandardArgs.cmake:91 (MESSAGE):
Could NOT find OpenNI (missing: OPENNI_LIBRARY OPENNI_INCLUDE_DIR)

Call Stack (most recent call first):
D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardAr
gs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
nestk/cmake/FindOpenNI.cmake:51 (find_package_handle_standard_args)
nestk/cmake/find_nestk_deps.cmake:77 (FIND_PACKAGE)
build/nestk/UseEmbeddedNestk.cmake:23 (INCLUDE)
nestk/CMakeLists.txt:67 (INCLUDE)

Does anyone have any idea how I have to solve this? I’ve installed OpenNI, it’s installed at D:\Program Files\OpenNI.

like image 777
hhoud Avatar asked Oct 20 '11 13:10

hhoud


1 Answers

For biulding an OpenNI project with CMAKE you can wirte this in your cmakelists. It works fine. (I also included NITE2, but if you don't needed just delete those lines).

OPTION (ENABLE_OPENNI2_NITE2 ON)

IF( ENABLE_OPENNI2_NITE2 )
set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER})
FIND_LIBRARY( OPENNI2_LIBRARY
             NAMES OpenNI2
             HINTS ${PC_OPENNI2_LIBDIR} ${PC_OPENNI2_LIBRARY_DIRS} /usr/lib
             PATHS "$ENV{PROGRAMFILES}/OpenNI2/Lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/OpenNI2/Lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/OpenNI2"
             PATH_SUFFIXES lib lib64
)
FIND_PATH( OPENNI2_INCLUDE_DIR OpenNI.h
          HINTS ${PC_OPENNI2_INCLUDEDIR} ${PC_OPENNI2_INCLUDE_DIRS} 
                  /usr/include/openni2 /usr/include/ni2
                  PATHS "$ENV{PROGRAMFILES}/OpenNI2/include" "$ENV{PROGRAMW6432}/OpenNI2/include"
          PATH_SUFFIXES openni2 ni2)

FIND_LIBRARY( NITE2_LIBRARY
             NAMES NiTE2
             HINTS ${PC_OPENNI2_LIBDIR} ${PC_OPENNI2_LIBRARY_DIRS} /usr/lib
             PATHS "$ENV{PROGRAMFILES}/PrimeSense/NiTE2/lib${OPENNI2_SUFFIX}" "$ENV{PROGRAMW6432}/PrimeSense/NiTE2/lib${OPENNI2_SUFFIX}"
             PATH_SUFFIXES lib
)
FIND_PATH( NITE2_INCLUDE_DIR NiTE.h
          HINTS ${PC_OPENNI2_INCLUDEDIR} ${PC_OPENNI2_INCLUDE_DIRS} /usr/include/openni2 /usr/include/nite2
          PATHS "$ENV{PROGRAMFILES}/PrimeSense/NiTE2/include" "$ENV{PROGRAMW6432}/PrimeSense/NiTE2/include"
          PATH_SUFFIXES openni2         
)
ENDIF( ENABLE_OPENNI2_NITE2 )

And later you need to link the directories and libs found:

link_directories( ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} )
INCLUDE_DIRECTORIES( ${OPENNI2_INCLUDE_DIR} ${NITE2_INCLUDE_DIR} )
target_link_libraries( project ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} )
like image 79
Jav_Rock Avatar answered Sep 18 '22 12:09

Jav_Rock