尝试使用CMakeLists.txt构建OpenNI示例,但收到错误

时间:2012-10-07 12:43:18

标签: compilation cmake openni

我疯了自己的CMakeLists.txt文件来构建OpenNI示例。我成功构建了NiSimpleViewer。但是当尝试使用NiUserTracker时,我收到了这个错误:

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

这是我使用的CMakeLists。请告诉我它有什么问题?

http://pastebin.com/SMYjjU35

build /之外的文件夹内容是

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

1 个答案:

答案 0 :(得分:0)

我想,这是因为这一行:

link_directories(${OPENNI_LIBRARY})

link_directories()命令设置应搜索库的路径,因此您需要${OPENNI_LIBRARY_DIRS}之类的内容。