Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Building from source

Chadwick Boulay edited this page Mar 4, 2019 · 58 revisions

Overview

This page will explain how to build the project from source on either Win10 or OS X. If all you want to do is run the service without modifications, you might instead consider downloading pre-built binaries from the Release page.

Downloading the source

Don't download the source from the green "Clone or download" button! The zip provided only contains the source from the /src folder and not the submodules in /thirdparty. This is a known issue with GitHub (we don't provide the zip file that this button generates). If you don't have a github client installed, get it from: https://desktop.github.com/

git clone --recursive https://github.com/cboulay/PSMoveService.git

cd PSMoveService

Prerequisites and Build

Before you get started, think about whether you want to build for 32-bit or 64-bit architecture. SteamVR is 64-bit by default, so if you plan to use the openvr plugin then at least PSMoveClient should be 64-bit. The non-free closed-source CL Eye drivers only work on 32-bit; if you plan to use that then you should build PSMoveService for 32-bit. The below instructions are for 64-bit in MSVC 2015 but can be adapted to 32-bit and other versions of Visual Studio at the appropriate steps. For the majority of steps, the only difference is in choosing the correct CMake generator.

Prerequisites

  1. CMake
    • 3.6.1 works as of this writing.
  2. Compiler - Visual Studio 2015
  3. Boost
    • From here, get boost_1_61_0-msvc-14.0-64.exe.
    • Also get boost_1_61_0-msvc-14.0-32.exe if you plan to make 32-bit builds.
    • Install to default C:\local (i.e., resulting in C:\local\boost_1_61_0\)
    • This path will be referred to BOOST_ROOT later
  4. Optional: CL Eye Driver or CL Eye SDK

Initial Setup Script

  1. Run the InitialSetup_X64.bat Batch Script
    • This script will automatically configure and build the dependencies in the thirdparty folder.
    • It will ask you for the root install folder of Boost 1.61.
    • If you want to do a 32-bit build, run the 32-bit version of the InitialSetup.
      • NOTE: This will clear out all previously built intermediates in the /build and /deps folder
    • If you would rather do initial setup by hand, then proceed to the next step
  2. After the initial setup phase, if you add source files or other CMake changes you can run GenerateProjectFiles_X64.bat to regenerate the PSMoveService solution.

Manual Initial Setup (alternative to setup scripts)

  1. protobuf
    • cd to thirdparty\protobuf
    • mkdir vsprojects & cd vsprojects
    • cmake -G "Visual Studio 14 2015 Win64" -Dprotobuf_DEBUG_POSTFIX="" -Dprotobuf_BUILD_TESTS=OFF ../cmake
      • Drop the Win64 from the generator argument if building for 32-bit
    • Open PSMoveService\thirdparty\protobuf\vsprojects\protobuf.sln
    • Select Release|x64 and Build > Rebuild Solution
    • Select Debug|x64 and Build > Rebuild Solution
    • For 64-bit PSMoveService:
      • copy Debug\*.* x64\Debug
      • copy Release\*.* x64\Release
  2. libusb
    • Only necessary for PS3EYEDriver (Required in Mac and in Windows if using 64-bit PSMoveService)
    • Open PSMoveService\thirdparty\libusb\msvc\libusb_2015.sln
    • For each combination of Release/Debug * Win32/x64, right-click on libusb-1.0 (static) and Build.
    • Close this Visual Studio Solution.
  3. SDL2
    • Optional - Only required if you are building the configuration client. Highly recommended.
    • cd third_party/SDL2
    • mkdir build & cd build
    • cmake .. -G "Visual Studio 14 2015 Win64" -DDIRECTX=OFF -DDIRECTX=OFF -DSDL_STATIC=ON -DFORCE_STATIC_VCRT=ON -DEXTRA_CFLAGS="-MT -Z7 -DSDL_MAIN_HANDLED -DWIN32 -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -DHAVE_LIBC -D_USE_MATH_DEFINES
    • Open the solution (PSMoveService\thirdparty\SDL2\build\SDL2.sln)
    • For each Release/Debug target
      • Build the SLD2-static and SDL2main projects (Not the SDL2 project)
  4. Create Visual Studio project files
    • cd ../../..
    • mkdir build && cd build
    • cmake -G "Visual Studio 14 2015 Win64" -DOpenCV_DIR="C:\OpenCV-3.1.0\build" -DBOOST_ROOT="C:\local\boost_1_61_0" -DBOOST_LIBRARYDIR="C:\local\boost_1_61_0\lib64-msvc-14.0" ..

Build

  1. Open <path_to_repo>\build\PSMoveService.sln
  2. Change to "Release" configuration
  3. Rt-click on the OpenCV External project and build
  • This will download OpenCV 3.1 into the /deps folder and compile it
  1. Rt-click on the PSMoveService solution and build (or do a "Build All..." from the build menu)

Prerequisites

  1. Compiler
    • Tested with XCode/clang. gcc may work.
  2. Homebrew
    • I am opting for a system install of dependent libraries where possible, instead of project-specific.
    • Install homebrew if you do not already have it.
    • brew update
  3. Eigen3
    • brew install eigen
  4. OpenCV
    • brew tap homebrew/science
    • brew install opencv3 --HEAD --without-test
  5. Boost
    • brew install boost
  6. protobuf
    • brew install protobuf
  7. libusb
    • Currently I am using brew's libusb (brew install libusb), but previously I had to build myself (can't remember why); see below.
    • cd thirdparty/libusb
    • ./autogen.sh
    • ./configure
    • ./configure (yes, a second time)
    • make
  8. Optional: SDL2
    • Optional - Only required if you are building the the configuration tool.
    • brew install SDL2

Generate PSMoveService Xcode project files

  1. mkdir build && cd build
  2. cmake .. -G Xcode

Build PSMoveService

  1. Launch Xcode
  2. Open <path_to_repo>\build\PSMoveService.xcodeproj
  3. Go to "Product" > "Build" or hit -B

Tested with Ubuntu 18.04 AMD64. Not quite ready.

Prerequisites

  1. Build tools
    • sudo apt-get install build-essential cmake git checkinstall pkg-config autoconf automake libtool
  2. Third party libraries from apt-get
    • sudo apt-get install libopencv-dev libsdl2-dev libeigen3-dev libbluetooth-dev libhidapi-dev libusb-1.0
  3. Third party libraries that must be built locally because we need static libs compiled with -fPIC
    • boost:
      • cd to a folder with a lot of space
      • wget -O boost.tar.bz2 "https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2"
      • tar xvfj boost.tar.bz2
      • cd boost_1_64_0
      • ./bootstrap.sh CXXFLAGS=-fPIC
      • TODO: Select only needed modules.
      • sudo ./b2 cxxflags=-fPIC link=static threading=multi -a install
    • protobuf:
      • cd PSMoveService/thirdparty/protobuf
      • Update protobuf: git fetch && git pull origin master (or something... sorry I don't remember the exact command)
      • ./autogen.sh
      • ./configure --enable-shared --with-pic
      • make -j $(($(nproc) + 1))
      • sudo make install
      • sudo ldconfig

Generate project files

  1. `cd ~/PSMoveService
  2. mkdir build && cd build
  3. cmake ..
  4. make .
Clone this wiki locally