在 Linux 上安装 OSVR - 设置二进制目录

Installing OSVR on Linux - Setting binary directory

我目前正在尝试安装 OSVR-Core on my Debian 9.1 system. I installed all the prerequisites and followed this 教程。现在我坚持做这个项目。我创建了一个构建目录并尝试 运行

cmake -DCMAKE_PREFIX_PATH="/usr/local/stow/libfunctionality" ~/src/OSVR-Core

但我得到错误,我的二进制目录应该与我的源目录不同。我的源目录(带有 make 文件)应该是 ~/src/OSVR-Core 并且因为我在 ~/src/OSVR-Core/build 中,所以我认为这就足够了。

如何(以及在​​哪里)更改二进制目录的位置?我尝试了命令行选项 -D CMAKE_BINARY_DIR= "path/to/OSVR-Core/build 但没有用。我在网上看到,你不应该手动设置二进制目录,而是 created/calculated.

这是 CMakeError.log 文件:

    Determining if the pthread_create exist failed with the following output:
Change Dir: /home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_42e59/fast"
/usr/bin/make -f CMakeFiles/cmTC_42e59.dir/build.make CMakeFiles/cmTC_42e59.dir/build
make[1]: Entering directory '/home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_42e59.dir/CheckSymbolExists.c.o
/usr/bin/cc     -o CMakeFiles/cmTC_42e59.dir/CheckSymbolExists.c.o   -c /home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_42e59
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_42e59.dir/link.txt --verbose=1
/usr/bin/cc       CMakeFiles/cmTC_42e59.dir/CheckSymbolExists.c.o  -o cmTC_42e59 -rdynamic 
CMakeFiles/cmTC_42e59.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_42e59.dir/build.make:97: recipe for target 'cmTC_42e59' failed
make[1]: *** [cmTC_42e59] Error 1
make[1]: Leaving directory '/home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_42e59/fast' failed
make: *** [cmTC_42e59/fast] Error 2

File /home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output: Change Dir: /home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_f2984/fast"
/usr/bin/make -f CMakeFiles/cmTC_f2984.dir/build.make CMakeFiles/cmTC_f2984.dir/build
make[1]: Entering directory '/home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_f2984.dir/CheckFunctionExists.c.o
/usr/bin/cc    -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_f2984.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.7/Modules/CheckFunctionExists.c
Linking C executable cmTC_f2984
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f2984.dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_f2984.dir/CheckFunctionExists.c.o  -o cmTC_f2984 -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_f2984.dir/build.make:97: recipe for target 'cmTC_f2984' failed
make[1]: *** [cmTC_f2984] Error 1
make[1]: Leaving directory '/home/lenala/src/OSVR-Core/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_f2984/fast' failed
make: *** [cmTC_f2984/fast] Error 2

你用过

cmake .. -DJSONCPP_WITH_CMAKE_PACKAGE=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -DCMAKE_CXX_FLAGS=-fPIC

因为这就是教程所说的用于构建项目的内容,并且 CMakaList.txt 将处理所有路径。

我设法让它工作了。我在 ~/src 目录中重新安装了 libfunctionality。然后我删除了 OSVR-core 的 github 存储库并再次克隆它。之后它起作用了,使用:

$ cmake .. -DJSONCPP_WITH_CMAKE_PACKAGE=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -DCMAKE_CXX_FLAGS=-fPIC $ make