2012-10-07 55 views
0

我生我自己的CMakeLists.txt文件來構建OpenNI示例。我成功構建了NiSimpleViewer。但是,當嘗試用NiUserTracker我得到這個錯誤:嘗試使用CMakeLists.txt構建OpenNI示例,但出現錯誤

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

文件夾之外構建的內容/是

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

回答

0

我想,這是因爲這行:

link_directories(${OPENNI_LIBRARY}) 

link_directories()命令集合,其中庫應搜索路徑因爲,所以你需要像${OPENNI_LIBRARY_DIRS}這樣的東西。

+0

更好的是,完全刪除'link_directories'命令。這裏不需要它,[它自己的文檔](http://www.cmake.org/cmake/help/v2.8.9/cmake.html#command:link_directories)不鼓勵它的使用。 – Fraser

+0

現在有什麼錯誤? – arrowd

+0

完成!結果:same :(無法建立 'Linking CXX executable main 架構x86_64的未定義符號: 「DrawDepthMap(xn :: DepthMetaData const&,xn :: SceneMetaData const&)」,引用來自: glutDisplay()in main .cpp.o 「MyPoseInProgress(xn :: PoseDetectionCapability&,char const *,unsigned int,XnPoseDetectionStatus,void *)」,引用來自: _main in main.cpp.o 「MyCalibrationInProgress(xn :: SkeletonCapability&,unsigned int, XnCalibrationStatus,void *)「,引用來自: _main in main.cpp.o ld:symbol(s)not found for architecture x86_64' –

相關問題