本文介绍了CMAKE找不到OpenNI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图运行教程开始与Kinect库(http://nicolas.burrus.name/index.php/Research/KinectUseNestk),但我偶然发现一个错误。



当我在CLI中尝试以下行时:

  cmake -DCMAKE_BUILD_TYPE = ReWithDebInfo .. 

我得到以下错误:

  CMake错误在D:/ Program Files / CMake 2.8 / share / cmake-2.8 / Modules / FindPackageHan 
dleStandardArgs.cmake:91(MESSAGE):
找不到OpenNI(缺少:OPENNI_LIBRARY OPENNI_INCLUDE_DIR)

调用堆栈(最近调用):
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 / /UseEmbeddedNestk.cmake:23(INCLUDE)
nestk / CMakeLists.txt:67(INCLUDE)

有没有人有任何想法如何我必须解决这个?我已经安装了OpenNI,它安装在D:\Program Files\OpenNI。

解决方案

CMAKE你可以wirte这在你的cmakelists。它工作正常。 (我也包括NITE2,但如果你不需要只是删除那些行)。

  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 / open2i / 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 / nite2
PATHS$ ENV {PROGRAMFILES} / PrimeSense / NiTE2 / include$ ENV {PROGRAMW6432} / PrimeSense / NiTE2 / include
PATH_SUFFIXES openni2

ENDIF(ENABLE_OPENNI2_NITE2 )

之后,您需要链接找到的目录和库:



link_directories($ {OPENNI2_LIBRARY} $ {NITE2_LIBRARY})
INCLUDE_DIRECTORIES($ {OPENNI2_INCLUDE_DIR} $ {NITE2_INCLUDE_DIR})
target_link_libraries {OPENNI2_LIBRARY} $ {NITE2_LIBRARY})


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.

解决方案

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} )

这篇关于CMAKE找不到OpenNI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:30