Skip to content

Commit 2ef6c48

Browse files
aras-plgritz
authored andcommitted
Docs: write Windows build instructions (AcademySoftwareFoundation#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 59b5165 commit 2ef6c48

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
@@ -269,8 +269,92 @@ Building on Windows
269269

270270
**Method 1 - from source**
271271

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

275359
**Method 2 - Using vcpkg**
276360

0 commit comments

Comments
 (0)