【问题标题】:Trying build OpenNI samples with CMakeLists.txt but getting error尝试使用 CMakeLists.txt 构建 OpenNI 示例但出现错误
【发布时间】:2012-10-07 12:43:18
【问题描述】:

我用自己的 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

【问题讨论】:

    标签: compilation cmake openni


    【解决方案1】:

    我猜,是因为这行:

    link_directories(${OPENNI_LIBRARY})
    

    link_directories() 命令设置了应该搜索库的路径,所以你需要类似${OPENNI_LIBRARY_DIRS} 这样的东西。

    【讨论】:

    • 更好的是,完全删除link_directories 命令。这里不需要它,its own documentation 不鼓励使用它。
    • 完成!结果:相同 :( 无法构建。Linking CXX executable main 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
    • 我想补充一点,我在其他 dir/project 中具有相同的 CMakeLists.txt,更简单的一个,以及 -L 之后的“ld: warning: path '/usr/lib/libOpenNI.dylib'不是目录”被抛出,但它会编译。所以这不是主要问题
    • 是否打算注释查找 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 -- Configuring done -- Generating done -- Build files have been written to: /Users/vkonovko7/_PROJECTS/KINECT-dev/error NiUserTracker CMakeLists/build 的输出
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 2013-01-26
    • 2011-12-03
    • 2020-06-16
    • 2021-08-18
    相关资源
    最近更新 更多