Skip to content

Commit 3a9d3fa

Browse files
authored
Docs: write Windows build instructions (#3602)
I recently wrote down how to build OIIO from source for myself (https://gist.github.com/aras-p/6497703c9b52f67761e6191343e43f7b), and maybe a slightly cleaned up version would be good to put into actual docs.
1 parent 4be5ca0 commit 3a9d3fa

File tree

1 file changed

+86
-2
lines changed

1 file changed

+86
-2
lines changed

INSTALL.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,92 @@ Building on Windows
268268

269269
**Method 1 - from source**
270270

271-
I really need someone to write correct, modern docs about how to build
272-
from source on Windows.
271+
You will need to have Git, CMake and Visual Studio installed.
272+
273+
The minimal set of dependencies for OIIO is: Boost, zlib, libTIFF, OpenEXR, and libjpeg or libjpeg-turbo. If you have them built somewhere then you skip
274+
the section below, and will only have to point OIIO build process so their locations.
275+
276+
* Boost: get the boost source archive, extract into `{BOOST_ROOT}`.
277+
```
278+
cd {BOOST_ROOT}
279+
bootstrap
280+
b2
281+
```
282+
* zlib: this will build it, and then delete the non-static library, so they don't get picked up:
283+
```
284+
cd {ZLIB_ROOT}
285+
git clone https://github.com/madler/zlib .
286+
mkdir build
287+
cd build
288+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=. ..
289+
cmake --build . --config Release --target install
290+
del lib\zlib.lib
291+
```
292+
* libTIFF:
293+
```
294+
cd {TIFF_ROOT}
295+
git clone https://gitlab.com/libtiff/libtiff.git .
296+
cd build
297+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=. ..
298+
cmake --build . --target install
299+
```
300+
* libjpeg-turbo:
301+
```
302+
cd {JPEG_ROOT}
303+
git clone https://github.com/libjpeg-turbo/libjpeg-turbo .
304+
mkdir build
305+
cd build
306+
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=. ..
307+
cmake --build . --config Release --target install
308+
```
309+
* OpenEXR: you'll have to point it to your `{ZLIB_ROOT}` location from the above. If copy-pasting the multi-line command (with lines ending in `^`) into
310+
cmd.exe prompt, make sure to copy all the lines at once.
311+
```
312+
cd {EXR_ROOT}
313+
git clone https://github.com/AcademySoftwareFoundation/openexr .
314+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist ^
315+
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DOPENEXR_BUILD_TOOLS=OFF ^
316+
-DOPENEXR_INSTALL_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF ^
317+
-DZLIB_ROOT={ZLIB_ROOT}\build ..
318+
cmake --build . --target install --config Release
319+
```
320+
321+
Now get the OIIO source and do one-time CMake configuration step. Replace `{*_ROOT}` below with folders where you have put the 3rd party
322+
dependencies.
323+
```
324+
cd {OIIO_ROOT}
325+
git clone https://github.com/OpenImageIO/oiio .
326+
mkdir build
327+
cd build
328+
cmake -DVERBOSE=ON -DCMAKE_BUILD_TYPE=Release ^
329+
-DBoost_USE_STATIC_LIBS=ON -DBoost_NO_WARN_NEW_VERSIONS=ON -DBoost_ROOT={BOOST_ROOT} ^
330+
-DZLIB_ROOT={ZLIB_ROOT}\build ^
331+
-DTIFF_ROOT={TIFF_ROOT}\build ^
332+
-DOpenEXR_ROOT={EXR_ROOT}\build\dist ^
333+
-DImath_DIR={EXR_ROOT}\build\dist\lib\cmake\Imath ^
334+
-DJPEG_ROOT={JPEG_ROOT}\build ^
335+
-DUSE_PYTHON=0 -DUSE_QT=0 -DBUILD_SHARED_LIBS=0 -DLINKSTATIC=1 ..
336+
```
337+
338+
This will produce `{OIIO_ROOT}/build/OpenImageIO.sln` that can be opened in Visual Studio IDE. Note that the solution will be
339+
only for the Intel x64 architecture only; and will only target "min-spec" (SSE2) SIMD instruction set.
340+
341+
Optional packages that OIIO can use (e.g. libpng, Qt) can be build and pointed to OIIO build process in a similar way.
342+
343+
In Visual Studio, open `{OIIO_ROOT}/build/OpenImageIO.sln` and pick Release build configuration. If you pick Debug, you
344+
might need to re-run the CMake command above with `-DCMAKE_BUILD_TYPE=Debug` and also have all the dependencies above built
345+
with `Debug` config too.
346+
347+
The main project that builds the library is `OpenImageIO`. The library is built into `{OIIO_ROOT}/build/lib/{CONFIG}` folder.
348+
The various OIIO command line tools (`oiiotool`, `iconvert` etc.) are projects under Tools subfolder in VS IDE solution explorer.
349+
They all build into `{OIIO_ROOT}/build/bin/{CONFIG}` folder.
350+
351+
There's a `CMakePredefinedTargets/INSTALL` project that you can build to produce a `{OIIO_ROOT}/dist` folder with `bin`, `include`,
352+
`lib`, `share` folders as an OIIO distribution.
353+
354+
The instructions above use options for building statically-linked OIIO library and tools. Adjust options passed to CMake to
355+
produce a dynamic-linked version.
356+
273357

274358
**Method 2 - Using vcpkg**
275359

0 commit comments

Comments
 (0)