The Imath library is available for download and installation in binary form via package managers on many Linux distributions. See https://pkgs.org/download/Imath for a complete list. The common ones that generally provide current releases include:
Beware that some distributions are out of date and only provide distributions of outdated releases OpenEXR. We recommend against using OpenEXR v2, and we strongly recommend against using OpenEXR v1.
On macOS, we do not recommend installation via HomeBrew because the distribution is outdated.
Please note that
pip install openexr installs the openexrpython module, which is not
affiliated with the OpenEXR project or the ASWF. Please direct
Build from Source¶
Imath builds on Linux, macOS, Microsoft Windows via CMake, and is cross-compilable on other systems.
release branch of the repo always points to the most advanced
Make sure these are installed on your system before building Imath:
Imath requires CMake version 3.14 or newer
C++ compiler that supports C++11
The instructions that follow describe building Imath with CMake.
To build via CMake, you need to first identify three directories:
The source directory, i.e. the top-level directory of the downloaded source archive or cloned repo, referred to below as
A temporary directory to hold the build artifacts, referred to below as
A destination directory into which to install the libraries and headers, referred to below as
% cd $builddir
% cmake $srcdir --install-prefix $installdir
% cmake --build $builddir --target install --config Release
Note that the CMake configuration prefers to apply an out-of-tree
build process, since there may be multiple build configurations
(i.e. debug and release), one per folder, all pointing at once source
tree, hence the
$builddir noted above, referred to in CMake
parlance as the build directory. You can place this directory
wherever you like.
See the CMake Configuration Options section below for the most common
configuration options especially the install directory. Note that with
no arguments, as above,
make install installs the header files in
/usr/local/include, the object libraries in
/usr/local/lib, and the
executable programs in
Under Windows, if you are using a command line-based setup, such as
cygwin, you can of course follow the above. For Visual Studio, cmake
generators are “multiple configuration”, so you don’t even have to set
the build type, although you will most likely need to specify the
install location. Install Directory By default,
installs the headers, libraries, and programs into
/usr/local, but you
can specify a local install directory to cmake via the
% cmake .. -DCMAKE_INSTALL_PREFIX=$Imath_install_directory
By default the installed libraries follow a pattern for how they are named. This is done to enable multiple versions of the library to be installed and targeted by different builds depending on the needs of the project. A simple example of this would be to have different versions of the library installed to allow for applications targeting different VFX Platform years to co-exist.
If you are building dynamic libraries, once you have configured, built, and installed the libraries, you should see the following pattern of symlinks and files in the install lib folder:
libImath.so -> libImath.so.31
libImath.so.$SOVERSION -> libImath.so.$SOVERSION.$RELEASE
libImath.so.$SOVERSION.$RELEASE (the shared object file)
SOVERSION number identifies the ABI version. Each Imath
release that changes the ABI in backwards-incompatible ways increases
this number. By policy, this changes only for major and minor
releases, never for patch releases.
RELEASE is the
MAJOR.MINOR.PATCH release name. For example, the resulting shared
library filename is
libImath.so.22.214.171.124 for Imath release
v3.1.10. This naming scheme reinforces the correspondence between the
real filename of the
.so and the release it corresponds to.
IMATH_LIB_SUFFIX CMake option designates a suffix for the
library and appears between the library base name and the
.so. This defaults to encode the major and minor version, as in
libImath.so -> libImath-3_1.so
libImath-3_1.so -> libImath-3_1.so.30
libImath-3_1.so.30 -> libImath-3_1.so.126.96.36.199
libImath-3_1.so.188.8.131.52 (the shared object file)
Porting Applications from OpenEXR v2 to v3¶
See the OpenEXR/Imath 2.x to 3.x Porting Guide for details about differences from previous releases and how to address them. Also refer to the porting guide for details about changes to Imath.
Building the Website¶
The Imath technical documentation at https://imath.readthedocs.io is generated via Sphinx with the Breathe extension using information
extracted from header comments by Doxygen,
using the sphinx-press-theme, and is hosted by
readthedocs. The website
source is in restructured text
To build the website locally from the source headers and
.rst files, set the CMake option
BUILD_WEBSITE=ON. This adds
website CMake target. Generation is off by default.
On Debian/Ubuntu Linux:
% apt-get install doxygen python3-sphinx
% pip3 install breathe
% pip3 install sphinx_press_theme
% mkdir _build
% cd _build
% cmake .. -DBUILD_WEBSITE=ON
% cmake --build . --target website
CMake Build-time Configuration Options¶
The default CMake configuration options are stored in
cmake/ImathSetup.cmake. To see a complete set of option
% cmake -LAH $imath_source_directory
You can customize these options three ways:
.cmakefiles in place.
Use the UI
Specify them as command-line arguments when you invoke cmake.
Library Naming Options¶
Append the given string to the end of all the Imath libraries. Default is
-<major>_<minor>version string. Please see the section on library names
The standard CMake path in which to search for dependencies, Imath in particular. A comma-separated path. Add the root directory where Imath is installed.
Public namespace alias for Imath. Default is
Real namespace for Imath that will end up in compiled symbols. Default is
Whether the namespace has been customized (so external users know)
Build the testing tree. Default is
ON. Note that this causes the test suite to be compiled, but it is not executed. To execute the suite, run “make test”.
Additional CMake Options¶
See the CMake documentation for more information (https://cmake.org/cmake/help/v3.12/).
For builds when not using a multi-configuration generator. Available values:
This is the primary control whether to build static libraries or shared libraries / dlls (side note: technically a convention, hence not an official
CMAKE_variable, it is defined within cmake and used everywhere to control this static / shared behavior)
C++ standard to compile against. This obeys the global
CMAKE_CXX_STANDARDbut doesn’t force the global setting to enable sub-project inclusion. Default is
The C++ compiler.
The C compiler.
For non-standard install locations where you don’t want to have to set
LD_LIBRARY_PATHto use them
Enable/Disable output of compile commands during generation. Default is
Echo all compile commands during make. Default is
Cross Compiling / Specifying Specific Compilers¶
When trying to either cross-compile for a different platform, or for tasks such as specifying a compiler set to match the VFX reference platform, cmake provides the idea of a toolchain which may be useful instead of having to remember a chain of configuration options. It also means that platform-specific compiler names and options are out of the main cmake file, providing better isolation.
A toolchain file is simply just a cmake script that sets all the
compiler and related flags and is run very early in the configuration
step to be able to set all the compiler options and such for the
discovery that cmake performs automatically. These options can be set
on the command line still if that is clearer, but a theoretical
toolchain file for compiling for VFX Platform 2015 is provided in the
source tree at
will hopefully provide a guide how this might work.
For cross-compiling for additional platforms, there is also an
included sample script in
cmake/Toolchain-mingw.cmake which shows
how cross compiling from Linux for Windows may work. The compiler
names and paths may need to be changed for your environment.
If you have Ninja installed, it is faster than make. You can generate ninja files using cmake when doing the initial generation:
% cmake -G “Ninja” ..