linuxcmakedebianosvr

Installing OSVR on Linux - Setting binary directory


I am currently trying to install OSVR-Core on my Debian 9.1 system. I installed all the prerequisites and followed this tutorial. Now I am stuck at making the project. I created a build-directory and tried running

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

but I get the error, that my binary directory should be different from my source directory. My source directory (with the make-files) should be ~/src/OSVR-Core and since I am in ~/src/OSVR-Core/build, I thought this was enough.

How (and where) do I change the location of the binary directory? I tried the command line option -D CMAKE_BINARY_DIR= "path/to/OSVR-Core/build but that did not work. I read online, that you should not set the Binary directory manually, but that it is created/calculated.

This is the CMakeError.log file:

    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

Solution

  • I managed to get it to work. I reinstalled libfunctionality in my ~/src directory. Then I removed the github repository of OSVR-core and cloned it again. After that it worked, using:

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