Installation of the xtensor-r C++ library

xtensor-r is a header-only C++ library. We maintain the conda package for xtensor-r and its dependencies.

Besides the xtendor-r headers, all these methods place the cmake project configuration file in the right location so that third-party projects can use cmake’s find_package to locate xtensor-r headers.


Using the conda-forge package

A package for xtensor-r is available on the mamba (or conda) package manager.

mamba install -c conda-forge xtensor-r

From source with cmake

You can also install xtensor-r from source with cmake. On Unix platforms, from the source directory:

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 install

Installation of the R package

We provide a R package for Xtensor on both conda and CRAN (Comprehensive R Archive Network). The packaging boilerplate for the R package is available at

To install the R package with conda:

conda install r-xtensor -c conda-forge

To install the R package from CRAN:


or from the GitHub repository using devtools:



A key difference between the version of the R package available on CRAN and conda is that

  • the CRAN package vendors the headers of xtl, xsimd, xtensor, and xtensor-r.

  • the conda package depends on the conda packages for xtl, xsimd, xtensor and xtensor-r.

When installing the package from CRAN, it is still possible to drop the vendored dependencies by adding the --configure-args='--novendor' option to the R CMD INSTALL command, or by defining the NO_VENDOR_XTENSOR environment variable to YES.