Installation

xtensor-io is a header-only library but depends on some traditional libraries that need to be installed. On Linux, installation of the dependencies can be done through the package manager, anaconda or manual compilation.

_images/conda.svg

Using the conda package

A package for xtensor-io is available on the conda package manager. The package will also pull all the dependencies (OpenImageIO, libsndfile and zlib).

conda install xtensor-io -c conda-forge

The easiest way to make use of xtensor-io in your code is by using cmake for your project. In order for cmake to pick up the xtensor-io dependency, just utilize the interface target and link the xtensor-io library to your target.

add_executable(my_exec my_exec.cpp)
target_link_libraries(my_exec
  PUBLIC
    xtensor-io
)

This should be enough to add the correct directories to the include_directories and link the required libraries. However, depending on your system setup there might be problmes upon executing, as the dynamic library is not picked up correctly. So if you run into errors that read something like “Library could not be opened … “, then set the RPATH, the runtime library search path, to the conda library path of your environment. We utilize the CMAKE_INSTALL_PREFIX for this purpose, so if you call cmake like this cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX and add the following to your CMakeLists.txt.

set_target_properties(my_exec
  PROPERTIES
    INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
    BUILD_WITH_INSTALL_RPATH ON
)
_images/cmake.svg

From source with cmake

You can also install xtensor-io from source with cmake. On Unix platforms, from the source directory: However, you need to make sure to have the required libraries available on your machine. Note: you don’t need all libraries if you only use parts of xtensor-io. libsndfile is required for xaudio, OpenImageIO for ximage and zlib for xnpz.

Installation of the dependencies on Linux:

# Ubuntu / Debian
sudo apt-get install libsndfile-dev libopenimageio-dev zlib1g-dev
# Fedora
sudo dnf install libsndfile-devel OpenImageIO-devel zlib-devel
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/prefix ..
make install

On Windows platforms, from the source directory:

mkdir build
cd build
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=/path/to/prefix ..
nmake
nmake install