0

I have mad my own CMakeLists.txt file to build OpenNI samples. I successfully build NiSimpleViewer. But when try with NiUserTracker I get this error:

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

This is the CMakeLists I use. Plese tell me what's wrong with it?

http://pastebin.com/SMYjjU35

The contents of folder outside build/ are

CMakeLists.txt  Libs            build           opengles.cpp
GL              SceneDrawer.cpp glh             opengles.h
GLES            SceneDrawer.h   main.cpp
Vito Valov
  • 1,765
  • 1
  • 19
  • 37

1 Answers1

0

I guess, it's because of this line:

link_directories(${OPENNI_LIBRARY})

The link_directories() command sets path where libraries should be searched for, so you need something like ${OPENNI_LIBRARY_DIRS} there.

arrowd
  • 33,231
  • 8
  • 79
  • 110
  • Better still, remove the `link_directories` command altogether. It shouldn't be needed here, and [its own documentation](http://www.cmake.org/cmake/help/v2.8.9/cmake.html#command:link_directories) discourages its use. – Fraser Oct 07 '12 at 14:15
  • Done! result: same :( can't build. `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` – Vito Valov Oct 07 '12 at 15:46
  • I want to add that I have the same CMakeLists.txt in other dir/project , simpler one, and the "ld: warning: path '/usr/lib/libOpenNI.dylib' following -L not a directory" is thrown, however it compiles. So this is not a main problem – Vito Valov Oct 07 '12 at 15:50
  • Is it intended that code for finding OpenGL and GLUT is commented? If this doesn't help, there might be some issue with arch for which OpenNI was built (you didn't compile it yourself)? Otherwise, i can't help with this, sorry. – arrowd Oct 07 '12 at 16:23
  • Yes it's commented as the part that finds successfully is above. The other is not necessary. OpenGL and GLUT frameworks are found without problem. Here you see the output of 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` – Vito Valov Oct 07 '12 at 16:37