帮助解决编译错误

帮助解决编译错误

我已经编译好了我已经为 natty 编译了 libfreenect 并且现在我正尝试安装 kinect 鼠标:https://github.com/Ooblik/Kinect-Mouse/ 但是当我输入时make我收到一个错误......

这是终端:

eric@eric-desktop:~$ cd /home/eric/kinect_mouse
eric@eric-desktop:~/kinect_mouse$ mkdir build
eric@eric-desktop:~/kinect_mouse$ cd build
eric@eric-desktop:~/kinect_mouse/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/eric/kinect_mouse/build
eric@eric-desktop:~/kinect_mouse/build$ make
Scanning dependencies of target kmouse
[100%] Building C object CMakeFiles/kmouse.dir/kinect_mouse.c.o
Linking C executable kmouse
CMakeFiles/kmouse.dir/kinect_mouse.c.o: In function `freenect_threadfunc':
kinect_mouse.c:(.text+0xd6d): undefined reference to `freenect_set_video_format'
kinect_mouse.c:(.text+0xd81): undefined reference to `freenect_set_depth_format'
collect2: ld returned 1 exit status
make[2]: *** [kmouse] Error 1
make[1]: *** [CMakeFiles/kmouse.dir/all] Error 2
make: *** [all] Error 2
eric@eric-desktop:~/kinect_mouse/build$

答案1

该错误表示缺少库。grep -rn freenect_set_video_format .在包含以下内容的目录中执行操作时libfreenect,发现fakenect/fakenect.c包含所需的功能。读取fakenect/自述文件明确指出您在构建时需要链接到该库kinect_mouse

因此,编辑kinect_mouse/CMakeLists.txtlink_directories(/usr/local/lib64/fakenect)输入:

cmake_minimum_required(VERSION 2.8)

link_directories(/usr/local/lib64/fakenect)

add_executable(kmouse kinect_mouse.c)

清除您的构建目录并重新构建。

相关内容