我有一个使用头文件OpenNI.h的代码,我正在使用CMake。每次我运行make我都会收到错误:
[ 33%] Linking CXX executable oniproject
CMakeFiles/oniproject.dir/main.cpp.o: In function `openni::VideoStream::start()':
main.cpp:(.text._ZN6openni11VideoStream5startEv[_ZN6openni11VideoStream5startEv]+0x31):>undefined reference to `oniStreamStart'
collect2: error: ld returned 1 exit status
我的CMakeLists.txt
看起来像
find_library(OPENNI2_LIBRARY
NAMES OpenNI
PATHS /usr/lib64
)
find_path (OPENNI2_INCLUDES OpenNI.h
/usr/local/src/OpenNI2/Include
)
include_directories(${OPENNI2_INCLUDES})
# practice
add_executable(oniproject
main.cpp
Viewer.cpp
Viewer.h
)
target_link_libraries(oniproject ${OPENNI2_LIBRARY})
target_link_libraries(oniproject ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} )
include_directories (${LIBUSB_INCLUDE_DIRS})
link_directories (${LIBUSB_LIBRARY_DIRS})
有人可以告诉我如何解决这个问题吗?