gpt4 book ai didi

c++ - 是否有用于 OpenNI2 的 CMakeLists?

转载 作者:行者123 更新时间:2023-11-30 04:03:07 25 4
gpt4 key购买 nike

大家好!

我一直在网上搜索是否有适合 OpenNI 2 的 CMakelist 命令,但没有找到任何似乎有效的命令。我在下一页找到了一个 CMakelists: CMAKE can't find OpenNI但事实证明它对我不起作用。我正在使用 Ubuntu 10.04,我的 CMakeLists.txt 如下所示:

cmake_minimum_required(VERSION 2.8)

project( DisplayImage )

# ***************************************
# OpenCV

find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
# ***************************************

# *************************************
# OpenNI 2

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 )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenNI2 DEFAULT_MSG
OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR)

mark_as_advanced(OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR)

if (OPENNI2_FOUND)
INCLUDE_DIRECTORIES( ${OPENNI2_INCLUDE_DIR} ${NITE2_INCLUDE_DIR} )
message (STATUS "OpenNI2 found (include: ${OPENNI2_INCLUDE_DIR}, lib: ${OPENNI2_LIBRARY})")
link_directories( ${OPENNI2_LIBRARY} ${NITE2_LIBRARY}
endif (OPENNI2_FOUND))
# *************************************

# *************************************
# My source codes
# set (SRC_DIR src)
# set (BUILD_DIR build)
# set (INC_DIR include)

# add the binary tree to the search path for include files
# so that we will find the header file
# include_directories("${INC_DIR}")

# you must add the list of your source files for the current target
# set (HEADERS ${INC_DIR}/printer.h)

# *************************************

# *************************************
# Set the output directories
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR}/bin ) # this is for the binary file
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIR}/arc) # this is for the archives
set (CMAKE_LIBRARIES_OUTPUT_DIRECTORY ${BUILD_DIR}/lib) # this is for the libraries
# *************************************

add_executable( DisplayImage main.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} )

当我尝试编译程序时,终端显示以下错误消息:

-- Could NOT find OpenNI2 (missing:  OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR) 
CMake Error in CMakeLists.txt:
A logical block opening on the line

/home/charly/OpenCV Test/KinectDisplay/src/CMakeLists.txt:51 (if)

is not closed.


-- Configuring incomplete, errors occurred!
make: *** [cmake_check_build_system] Error 1

但 OpenNI2 目录与上述 CMakeLists 中的目录相同。我错过了什么?提前致谢!

最佳答案

我认为错误在于:

link_directories( ${OPENNI2_LIBRARY} ${NITE2_LIBRARY} 

您缺少右括号,因此具有 endif 的下一行被视为目录而不是 if 结束。

此外,这个 cmake 只能在 Windows 中工作...我在 Linux 中使用过 openni2,“安装”只是 usb 和两个环境变量的规则....

所以,如果你想为你的程序制作一个可移植版本,你可能需要为 linux 情况添加一些 if(可能还有 mac,但我没有在 mac 中使用它,所以我不能告诉你太多关于它)

关于c++ - 是否有用于 OpenNI2 的 CMakeLists?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24679440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com