CMAKE找不到OpenNI

发布于 2024-12-10 20:47:17 字数 854 浏览 0 评论 0原文

我一直在尝试使用 Kinect 库运行“入门教程”(http://nicolas.burrus.name/index.php/Research/KinectUseNestk),但我偶然发现了一个错误。

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

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

我收到以下错误:

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)

有人知道我必须如何解决这个问题吗?我已经安装了 OpenNI,它安装在 D:\Program Files\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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

以往的大感动 2024-12-17 20:47:17

要使用 CMAKE 构建 OpenNI 项目,您可以将其写入 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/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 )

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

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

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} )
坦然微笑 2024-12-17 20:47:17

您可以尝试修改 CMakeLists.txt 文件并添加或修改以下行,

set(OPENNI_INCLUDE_DIR "D:/Program Files/OpenNI/Include")
set(OPENNI_LIB_DIR "D:/Program Files/OpenNI/Lib")

否则,请在二进制文件夹中查找名为 CMakeCache.txt 的文件。查找 OPENNI_INCLUDE_DIR 和 OPENNI_LIB_DIR,设置正确的路径,然后再次运行 cmake。

如果这些都不起作用,并且您可以运行 cmake-gui,请尝试使用它而不是 cli 命令并在 GUI 中手动指定这些路径。

我希望它有帮助!

You could try to modify the CMakeLists.txt file and add or modify the following lines

set(OPENNI_INCLUDE_DIR "D:/Program Files/OpenNI/Include")
set(OPENNI_LIB_DIR "D:/Program Files/OpenNI/Lib")

Otherwise, look for a file named CMakeCache.txt inside the binaries folder. Look for OPENNI_INCLUDE_DIR and OPENNI_LIB_DIR, set the right path, and run cmake again.

If none of those work, and you can run cmake-gui, try to use it instead of the cli command and manually specify those paths in the GUI.

I hope it helps!

倒数 2024-12-17 20:47:17

确保 OPEN_NI_BIN、OPEN_NI_INCLUDE、OPEN_NI_INSTALL_PATH 环境变量均已设置并且它们指向正确的位置,因为检查 OPEN_NI 的 cmake 模块会检查这些值。
我遇到了同样的错误,但就我而言,这是混合 64 位和 32 位库的问题。我使用 32 位编译器构建 opencv,但 OpenNI 是 64 位。所以我卸载了所有 64 位版本,只留下 32 位版本,这使它可以工作。

亲切的问候,
丹尼尔

Make sure OPEN_NI_BIN, OPEN_NI_INCLUDE, OPEN_NI_INSTALL_PATH environment variables are all set and that they point to the right place, because the cmake module that checks for OPEN_NI checks those values.
I was getting the same error, but in my case, it was a problem mixing 64 and 32 bit libraries. I was building opencv with 32 bit compilers, but OpenNI was 64 bit. So I uninstalled all 64bit and left only 32 bit versions, which made it work.

Kind regards,
Daniel

魂ガ小子 2024-12-17 20:47:17

典型的 openni2 发行版具有以下文件 /OpenNI-Linux-Arm-2.2/OpenNIDevEnvironment

它描述了编译和链接所需的所有变量:

export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include
export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist

因此您需要导出这些变量,然后在启用 OpenNI2 的情况下运行 cmake:

$export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include
$export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist
$cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_OPENNI2=ON  ..

在 cmake 结果中的某处您应该看到:

-- OpenNI2:是(版本 2.2.0,版本 33)

Typical openni2 distribution has following file /OpenNI-Linux-Arm-2.2/OpenNIDevEnvironment

It has described all necessary variables to compile and link:

export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include
export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist

So you need to export these variables and then run the cmake with OpenNI2 enabled:

$export OPENNI2_INCLUDE=/opt/cbox/OpenNI-Linux-Arm-2.2/Include
$export OPENNI2_REDIST=/opt/cbox/OpenNI-Linux-Arm-2.2/Redist
$cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_OPENNI2=ON  ..

Somewhere in cmake result you should see:

-- OpenNI2: YES (ver 2.2.0, build 33)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文