Skip to content
Snippets Groups Projects
build-additional-dependencies.md 6.07 KiB
Newer Older
---
title: "Monado - Building Additional Dependencies"
layout: main
---

* TOC
{:toc}

## Dependencies needed to build Monado's additional drivers

[checked on Fedora 38]

### For the OpenHMD driver

    git clone https://github.com/OpenHMD/OpenHMD.git
    cd OpenHMD
    cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON
    sudo ninja -C build install
    sudo ln -s /usr/lib/pkgconfig/openhmd.pc /usr/lib64/pkgconfig

### For the libsurvive driver

Some other dependencies are needed.

* On Debian/Ubuntu:

      sudo apt install liblapacke-dev libopenblas-dev

* On Fedora:

      sudo dnf install openblas-devel lapack-devel

Then, libsurvice can be built and installed:

    git clone https://github.com/cntools/libsurvive.git
    cd libsurvive
    cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DOPENVR_INCLUDE_PATH=/home/degrande/Projects/VAirDraw/vairdraw-src/externals/openvr/headers
    sudo ninja -C build install

### For the Realsense driver

* On Debian/Ubuntu: ```...```
* On Fedora: ```dnf install librealsense-devel```

### For the DepthAI driver

    git clone --recurse-submodules https://github.com/luxonis/depthai-core.git
    cd depthai-core
    cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON
    sudo ninja -C build install

### For SLAM tracking support, using Basalt 

Some other dependencies are needed.

* On Debian/Ubuntu:

      ...

* On Fedora:

      sudo dnf install tbb-devel glew-devel libpng-devel lz4-devel bzip2-devel boost-devel boost-regex boost-filesystem boost-date-time boost-program-options boost-serialization gtest-devel fmt-devel

\
**Basalt** uses Pangolin, which (in the included version) needs libuvc. On Debian/Ubuntu, it is packaged as ```libuvc-dev```, but it has to be built on Fedora:

      git clone https://github.com/libuvc/libuvc.git
      cd libuvc
      cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
      sudo ninja -C build install

\
**Note** Pangolin (in the included version) fails to compile with GCC 13, due to missing inclusions of ```<cstdint>``` (see https://www.gnu.org/software/gcc/gcc-13/porting_to.html, Header dependency changes).

    Add `#include <cstdint>` near the other inclusions in:
     * thirdparty/Pangolin/src/image/image_io_jpg.cpp
     * thirdparty/Pangolin/include/pangolin/log/packetstream_tags.h

\
Then, Basalt can be built and installed:

    git clone --recurse-submodules https://gitlab.freedesktop.org/mateosss/basalt
    cd basalt
    cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
    sudo ninja -C build install
    sudo ln -s /usr/lib/pkgconfig/basalt.pc /usr/lib64/pkgconfig

### For 'Mercury' Hand Tracking, using the ONNX Runtime

Some other dependencies are needed.

* On Debian/Ubuntu:

      ...

* On Fedora:

      sudo dnf install gmock-devel patch

\
Then, onnxruntime can be built and installed:

    git clone --recurse-submodules https://github.com/Microsoft/onnxruntime.git
    cd onnxruntime
    ./build.sh --config Release --build_shared_lib --parallel --skip_tests --compile_no_warning_as_error --cmake_extra_defines CMAKE_INSTALL_PREFIX=/usr --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF
    cd build/Linux/Release
    sudo make install

\
**Note** FlatBuffers fails to compile with GCC 13. A patch is to be applied to ignore a compilation warning (turned into an error). Once `onxxruntime.git` is cloned and before to run `./build.sh ...`, two modifications are needed:

1. Create a file named onnxruntime/cmake/patches/flatbuffers/flatbuffers_cmake.patch, with the following content:

       diff --git a/CMakeLists.txt b/CMakeLists.txt
       index 3987eac..5e5462f 100644
       --- a/CMakeLists.txt
       +++ b/CMakeLists.txt
       @@ -223,7 +223,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
              "${CMAKE_CXX_FLAGS} -std=c++0x")
          endif(CYGWIN)
          set(CMAKE_CXX_FLAGS
       -    "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
       +    "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow -Wno-error=stringop-overflow")
          set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
          if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
            if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)

1. Edit the file onnxruntime/cmake/external/onnxruntime_external_deps.cmake to change:

       #flatbuffers 1.11.0 does not have flatbuffers::IsOutRange, therefore we require 1.12.0+
       FetchContent_Declare(
           flatbuffers
           URL ${DEP_URL_flatbuffers}
           URL_HASH SHA1=${DEP_SHA1_flatbuffers}
           FIND_PACKAGE_ARGS 1.12.0...<2.0.0 NAMES Flatbuffers
       )

    into:

       #flatbuffers 1.11.0 does not have flatbuffers::IsOutRange, therefore we require 1.12.0+
       FetchContent_Declare(
           flatbuffers
           URL ${DEP_URL_flatbuffers}
           URL_HASH SHA1=${DEP_SHA1_flatbuffers}
           PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/flatbuffers/flatbuffers_cmake.patch
           FIND_PACKAGE_ARGS 1.12.0...<2.0.0 NAMES Flatbuffers
       )

Then, you can proceed with the compilation (`./build.sh ....`).

### For the UltraLeap driver

Get the latest Linux version from https://www2.leapmotion.com/v2-developer-beta-linux. \
Then (adapt the names to the downloaded version number):

    tar -xzf Leap_Motion_SDK_Linux_2.3.1.tgz
    cd LeapDeveloperKit_2.3.1+31549_linux/LeapSDK
    sudo cp include/Leap.h /usr/include
    sudo cp include/LeapMath.h /usr/include
    sudo cp lib/x64/libLeap.so /usr/lib64


### To use Tracy as a tracing backend

Some other dependencies are needed.

* On Debian/Ubuntu:

      ...

* On Fedora:

      sudo dnf install glfw-devel freetype-devel capstone-devel dbus-devel

\
Then, tracy can be built and installed:

    git clone git clone https://github.com/wolfpld/tracy.git
    cd tracy
    cd profiler/build/unix
    sudo make LEGACY=1

**Note**: Monado needs to be built with tracing support:

    cmake .... -DXRT_HAVE_TRACY=ON -DXRT_FEATURE_TRACING=ON