Compilation 尝试使用CMakeLists.txt构建OpenNI示例,但出现错误

Compilation 尝试使用CMakeLists.txt构建OpenNI示例,但出现错误,compilation,cmake,openni,Compilation,Cmake,Openni,我有自己的CMakeLists.txt文件来构建OpenNI示例。我成功地构建了NiSimpleViewer。但当我尝试使用Niuser Tracker时,我会出现以下错误: 35 warnings generated. Linking CXX executable main ld: warning: path '/usr/lib/libOpenNI.dylib' following -L not a directory Undefined symbols for architecture x8

我有自己的CMakeLists.txt文件来构建OpenNI示例。我成功地构建了NiSimpleViewer。但当我尝试使用Niuser Tracker时,我会出现以下错误:

35 warnings generated.
Linking CXX executable main
ld: warning: path '/usr/lib/libOpenNI.dylib' following -L not a directory
Undefined symbols for architecture x86_64:
  "DrawDepthMap(xn::DepthMetaData const&, xn::SceneMetaData const&)", referenced from:
      glutDisplay() in main.cpp.o
  "MyPoseInProgress(xn::PoseDetectionCapability&, char const*, unsigned int, XnPoseDetectionStatus, void*)", referenced from:
      _main in main.cpp.o
  "MyCalibrationInProgress(xn::SkeletonCapability&, unsigned int, XnCalibrationStatus, void*)", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [main] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
这是我使用的CmakeList。请告诉我有什么问题

内部版本/外部文件夹的内容是

CMakeLists.txt  Libs            build           opengles.cpp
GL              SceneDrawer.cpp glh             opengles.h
GLES            SceneDrawer.h   main.cpp

我想,这是因为这句话:

link_directories(${OPENNI_LIBRARY})

link\u directories()
命令设置了应该搜索库的路径,因此您需要类似于
${OPENNI\u LIBRARY\u DIRS}
的内容。

更好的是,将
link\u directories
命令一起删除。这里不需要它,不鼓励使用它。完成!结果:相同:(无法生成.
链接体系结构x86_64的CXX可执行文件主未定义符号:“DrawDepthMap(xn::DepthMetaData const&,xn::SceneMetaData const&)”,引用自main.cpp.o“MyPoseInProgress(xn::PoseDetectionCapability&,char const*,unsigned int,XnPoseDetectionStatus,void*)”,引用自:_mainin main.cpp.o“MyCalibrationProgress(xn::SkeletonCapability&,unsigned int,XnCalibrationStatus,void*),引用自:_mainin main.cpp.o ld:symbol(s)not found for architecture x86_64
我想补充的是,我在其他目录/项目中有相同的CMakeLists.txt,更简单的一个,以及“ld:warning:path'/usr/lib/libOpenNI.dylib'following-L not a directory”被抛出,但是它可以编译。所以这不是一个主要问题。它是否打算对查找OpenGL和GLUT的代码进行注释?如果这没有帮助,那么构建OpenNI的arch可能存在一些问题(您自己没有编译它)?否则,对不起,我帮不上忙。是的,它被注释为成功查找的部分在上面。另一个是不必要的。OpenGL和GLUT框架被找到没有问题。在这里,您可以看到cmake
——OpenNI found的输出(include:/usr/include/ni,lib:/usr/lib/libOpenNI.dylib/System/Library/Frameworks/AGL.framework/System/Library/Frameworks/OpenGL.framework/System/Library/Frameworks/GLUT.framework/Headers-framework-GLUT-framework-Cocoa——配置完成——生成完成——构建文件已写入:/Users/vkonovkonovko7/_项目/KINECT-dev/error-NiUser跟踪器CMakeLists/build