OIIO build instructions currently just say this for Windows:
Method 1 - from source I really need someone to write correct, modern docs about how to build from source on Windows.
So I decided to figure that out.
OIIO needs a handful of dependencies to be available/built/installed (OpenEXR, libTIFF, zlib, ...). For me, the easiest was to get and setup Blender codebase; just the "git clone + make update" steps. That checks out a bunch of precompiled libraries that Blender needs... among which is the subset that OIIO needs as well.
If you picked {BLENDER_ROOT}
as your base Blender codbase folder, then you'd end up with {BLENDER_ROOT}/blender
folder where the
git checkout is, and {BLENDER_ROOT}/lib/win64_vc15
with the 3rd party libraries, that is a result of make update
.
cd {OIIO_ROOT}
git clone https://github.com/OpenImageIO/oiio .
mkdir build
Replace {BLENDER_ROOT}
below with your actual Blender root folder. Then also copy Blender's zlib static library into a name that OIIO
build scripts expect, otherwise they won't find it.
cd OIIO_ROOT\build
set BLENDER={BLENDER_ROOT}\lib\win64_vc15
copy %BLENDER%\zlib\lib\libz_st.lib %BLENDER%\zlib\lib\zlibstatic.lib
cmake -DVERBOSE=ON -DCMAKE_BUILD_TYPE=Release ^
-DBoost_USE_STATIC_LIBS=ON -DBoost_NO_WARN_NEW_VERSIONS=ON -DBoost_ROOT=%BLENDER%\boost ^
-DZLIB_ROOT=%BLENDER%\zlib ^
-DTIFF_ROOT=%BLENDER%\tiff ^
-DOpenEXR_ROOT=%BLENDER%\openexr ^
-DImath_DIR=%BLENDER%\imath\lib\cmake\Imath ^
-DJPEG_ROOT=%BLENDER%\jpeg ^
-DPNG_ROOT=%BLENDER%\png ^
-DUSE_PYTHON=0 -DUSE_QT=0 -DBUILD_SHARED_LIBS=0 -DLINKSTATIC=1 ..
This will produce {OIIO_ROOT}/build/OpenImageIO.sln
that can be opened in Visual Studio. Note that the solution
will be only for the Intel x64 architecture only; and will only target "min-spec" (SSE2) SIMD instruction set.
The above command line also includes PNG support; this is not strictly necessary for OIIO but since Blender libraries already have it, then why not.
Open {OIIO_ROOT}/build/OpenImageIO.sln
and pick Release build configuration. If you pick Debug, you might need to re-run the CMake command above with -DCMAKE_BUILD_TYPE=Debug
, I'm not totally sure.
The main project that builds the library is OpenImageIO
. The library is built into {OIIO_ROOT}/build/lib/{CONFIG}
folder.
The various OIIO command line tools (oiiotool
, iconvert
, iinfo
etc.) are projects under Tools subfolder in VS IDE
solution explorer. They all build into {OIIO_ROOT}/build/bin/{CONFIG}
folder.
There's a CMakePredefinedTargets/INSTALL
project that you can build to produce a {OIIO_ROOT}/dist
folder with bin
, include
,
lib
, share
folders as a sort of "OIIO build ready for consumption from elsewhere" distribution.
Note: building INSTALL
target will also build the test executables, and in Release config building simd_test
takes forever.
The minimal set of dependencies for OIIO is: Boost, zlib, libTIFF, OpenEXR, and either libjpeg or libjpeg-turbo.
Get the boost source archive, extract into {BOOST_ROOT}
cd {BOOST_ROOT}
bootstrap
b2
This will build it, and then delete the non-static libraries, so they don't get picked up.
cd {ZLIB_ROOT}
git clone https://github.com/madler/zlib .
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --config Release --target install
del lib\zlib.lib
cd {TIFF_ROOT}
git clone https://gitlab.com/libtiff/libtiff.git .
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --target install
cd {JPEG_ROOT}
git clone https://github.com/libjpeg-turbo/libjpeg-turbo .
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --config Release --target install
You'll have to point it to your {ZLIB_ROOT}
location from the above.
cd {EXR_ROOT}
git clone https://github.com/AcademySoftwareFoundation/openexr .
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist ^
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DOPENEXR_BUILD_TOOLS=OFF ^
-DOPENEXR_INSTALL_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF ^
-DZLIB_ROOT={ZLIB_ROOT}\build ..
cmake --build . --target install --config Release
This is similar to the "use libraries from Blender" case above, instead it will point to individual locations where you have built the dependencies yourself.
cd {OIIO_ROOT}\build
cmake -DVERBOSE=ON -DCMAKE_BUILD_TYPE=Release ^
-DBoost_USE_STATIC_LIBS=ON -DBoost_NO_WARN_NEW_VERSIONS=ON -DBoost_ROOT={BOOST_ROOT} ^
-DZLIB_ROOT={ZLIB_ROOT}\build ^
-DTIFF_ROOT={TIFF_ROOT}\build ^
-DOpenEXR_ROOT={EXR_ROOT}\build\dist ^
-DImath_DIR={EXR_ROOT}\build\dist\lib\cmake\Imath ^
-DJPEG_ROOT={JPEG_ROOT}\build ^
-DUSE_PYTHON=0 -DUSE_QT=0 -DBUILD_SHARED_LIBS=0 -DLINKSTATIC=1 ..
And the rest is then the same.