visual-studio-2015buildcmake64-bitopenexr

How to build OpenEXR 2.2 using Visual Studio 14 2015 x64?


I am using CMake 3.7.1. I want to build OpenEXR 2.2 using Visual Studio 2015 x64. The release version contains detailed build instructions:

  1. Launch a command window, navigate to the IlmBase folder with CMakeLists.txt,and type command: setlocal del /f CMakeCache.txt cmake -DCMAKE_INSTALL_PREFIX= -G "Visual Studio 10 Win64" ..\ilmbase

  2. Navigate to IlmBase folder in Windows Explorer, open ILMBase.sln and build the solution. When it build successfully, right click INSTALL project and build. It will install the output to the path you set up at the previous step.

  3. Go to http://www.zlib.net and download zlib

  4. Launch a command window, navigate to the OpenEXR folder with CMakeLists.txt, and type command: setlocal del /f CMakeCache.txt cmake -DZLIB_ROOT= -DILMBASE_PACKAGE_PREFIX= -DCMAKE_INSTALL_PREFIX= -G "Visual Studio 10 Win64" ^ ..\openexr

  5. Navigate to OpenEXR folder in Windows Explorer, open OpenEXR.sln and build the solution. When it build successfully, right click INSTALL project and build. It will install the output to the path you set up at the previous step.

Step 1 to 2 work without a problem for me. The lib, dll and header files of IlmBase are stored in the "build" folder:

enter image description here

My executed instructions for Step 1 to 2:

wget.exe https://github.com/openexr/openexr/archive/v2.2.0.zip -OC:\thirdparty\vs2015\x64\openexr-2.2.0.zip
7za.exe x C:\thirdparty\vs2015\x64\openexr-2.2.0.zip -oC:\thirdparty\vs2015\x64
del C:\thirdparty\vs2015\x64\openexr-2.2.0.zip
C:
cd C:\thirdparty\vs2015\x64\openexr-2.2.0\IlmBase
cmake -G"Visual Studio 14 2015 Win64" -HC:\thirdparty\vs2015\x64\openexr-2.2.0 -BC:\build\vs2015\x64\openexr-2.2.0 ^
setlocal
del /f CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX="..\ilmbase\build" -G "Visual Studio 14 2015 Win64" ..\ilmbase
cmake --build . --config Release
cmake --build . --config Debug
cmake --build . --target INSTALL

Step 3 (downloading and building zlib-1.2.8) is also easy:

wget.exe http://zlib.net/zlib128.zip -OC:\thirdparty\vs2015\x64\zlib-1.2.8.zip
7za.exe x C:\thirdparty\vs2015\x64\zlib-1.2.8.zip -oC:\thirdparty\vs2015\x64
del C:\thirdparty\vs2015\x64\zlib-1.2.8.zip
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
cmake -G"Visual Studio 14 2015 Win64" -HC:\thirdparty\vs2015\x64\zlib-1.2.8 -BC:\build\vs2015\x64\zlib-1.2.8
C:
cd C:\build\vs2015\x64\zlib-1.2.8
cmake --build . --config Release
cmake --build . --config Debug
mkdir C:\thirdparty\vs2015\x64\zlib-1.2.8\lib
mkdir C:\thirdparty\vs2015\x64\zlib-1.2.8\bin
copy Debug\zlibd.dll C:\thirdparty\vs2015\x64\zlib-1.2.8\bin\zlibd.dll
copy Debug\zlibd.exp C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibd.exp
copy Debug\zlibd.ilk C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibd.ilk
copy Debug\zlibd.lib C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibd.lib
copy Debug\zlibd.pdb C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibd.pdb
copy Debug\zlibstaticd.lib C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibstaticd.lib
copy Release\zlib.dll C:\thirdparty\vs2015\x64\zlib-1.2.8\bin\zlib.dll
copy Release\zlib.exp C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlib.exp
copy Release\zlib.lib C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlib.lib
copy Release\zlibstatic.lib C:\thirdparty\vs2015\x64\zlib-1.2.8\lib\zlibstatic.lib
cd C:\thirdparty\vs2015\x64
rmdir C:\build\vs2015\x64\zlib-1.2.8 /S /Q

Now it comes to Step 4+5. I am executing the following statements:

cmake -DZLIB_ROOT="C:\thirdparty\vs2015\x64\zlib-1.2.8" ^
-DILMBASE_PACKAGE_PREFIX="C:\thirdparty\vs2015\x64\openexr-2.2.0\IlmBase\build" ^
-DCMAKE_INSTALL_PREFIX="..\OpenEXR\build" ^
-G "Visual Studio 14 2015 Win64" ^
..\openexr

I am opening the openexr.sln and than I try to build IlmInf. There is one error: "cmd.exe" exited with code -1073741515

enter image description here

Here is the error log:

4>------ Build started: Project: IlmImf, Configuration: Debug x64 ------ 
4>  Building Custom Rule C:/thirdparty/vs2015/x64/openexr-2.2.0/OpenEXR/IlmImf/CMakeLists.txt
4>  CMake does not need to re-run because C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\CMakeFiles\generate.stamp is up-to-date. 
4>  Generating b44ExpLogTable.h 
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code -1073741515.
========== Build: 3 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I don not understand why I get this error. What am I doing wrong here?

BTW: My batch scripts used to build zlib and OpenEXR can be found here: https://bitbucket.org/snippets/Vertexwahn/


Solution

  • IlmImf tries to run b44ExpLogTable.exe which requires the Half.dll file located at the right place. When copying the Half.dll, etc. files to the right location everything works fine.

    I use the following windows batch script to handle building OpenEXR and copying all the stuff to the right place:

    Build_openexr-2.2.0_Visual Studio 14 2015 Win64.cmd

    wget.exe https://github.com/openexr/openexr/archive/v2.2.0.zip -OC:\thirdparty\vs2015\x64\openexr-2.2.0.zip
    7za.exe x C:\thirdparty\vs2015\x64\openexr-2.2.0.zip -oC:\thirdparty\vs2015\x64
    del C:\thirdparty\vs2015\x64\openexr-2.2.0.zip
    C:
    cd C:\thirdparty\vs2015\x64\openexr-2.2.0\IlmBase
    cmake -DCMAKE_INSTALL_PREFIX="C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy" ^
    -G "Visual Studio 14 2015 Win64" ^
     ..\ilmbase
    setlocal
    del /f CMakeCache.txt
    cmake -DCMAKE_INSTALL_PREFIX="..\deploy" -G "Visual Studio 14 2015 Win64" ..\ilmbase
    cmake --build . --config Release
    cmake --build . --config RelWithDebInfo
    cmake --build . --config Debug
    cmake --build . --target INSTALL
    cd C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR
    setlocal
    del /f CMakeCache.txt
    cmake -DZLIB_ROOT="C:\thirdparty\vs2015\x64\zlib-1.2.11" ^
    -DILMBASE_PACKAGE_PREFIX="C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy" ^
    -DCMAKE_INSTALL_PREFIX="..\deploy" ^
    -G "Visual Studio 14 2015 Win64" ^
    ..\openexr
    
    mkdir C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Half.dll          C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release\Half.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Iex-2_2.dll       C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release\Iex-2_2.dll 
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IexMath-2_2.dll   C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release\IexMath.2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IlmThread-2_2.dll C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release\IlmThread-2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Imath-2_2.dll     C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Release\Imath-2_2.dll
    
    mkdir C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Half.dll          C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo\Half.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Iex-2_2.dll       C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo\Iex-2_2.dll 
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IexMath-2_2.dll   C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo\IexMath.2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IlmThread-2_2.dll C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo\IlmThread-2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Imath-2_2.dll     C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\RelWithDebInfo\Imath-2_2.dll
    
    mkdir C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Half.dll          C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug\Half.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Iex-2_2.dll       C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug\Iex-2_2.dll 
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IexMath-2_2.dll   C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug\IexMath.2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\IlmThread-2_2.dll C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug\IlmThread-2_2.dll
    copy C:\thirdparty\vs2015\x64\openexr-2.2.0\deploy\lib\Imath-2_2.dll     C:\thirdparty\vs2015\x64\openexr-2.2.0\OpenEXR\IlmImf\Debug\Imath-2_2.dll
    
    cmake --build . --config Release
    cmake --build . --config RelWithDebInfo
    cmake --build . --config Debug
    cmake --build . --target INSTALL
    

    Building OpenEXR requires a prebuild zlib version. I build zlib using the following script:

    Build_zlib-1.2.11_Visual Studio 14 2015 Win64.cmd

    wget.exe http://zlib.net/zlib1211.zip -OC:\thirdparty\vs2015\x64\zlib-1.2.11.zip
    7za.exe x C:\thirdparty\vs2015\x64\zlib-1.2.11.zip -oC:\thirdparty\vs2015\x64
    del C:\thirdparty\vs2015\x64\zlib-1.2.11.zip
    call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
    cmake -G"Visual Studio 14 2015 Win64" -HC:\thirdparty\vs2015\x64\zlib-1.2.11 -BC:\thirdparty\vs2015\x64\zlib-1.2.11\build
    C:
    cd C:\thirdparty\vs2015\x64\zlib-1.2.11\build
    cmake --build . --config Debug
    cmake --build . --config Release
    cmake --build . --config RelWithDebInfo
    mkdir C:\thirdparty\vs2015\x64\zlib-1.2.11\lib
    mkdir C:\thirdparty\vs2015\x64\zlib-1.2.11\bin
    copy Debug\zlibd.dll C:\thirdparty\vs2015\x64\zlib-1.2.11\bin\zlibd.dll
    copy Debug\zlibd.exp C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibd.exp
    copy Debug\zlibd.ilk C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibd.ilk
    copy Debug\zlibd.lib C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibd.lib
    copy Debug\zlibd.pdb C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibd.pdb
    copy Debug\zlibstaticd.lib C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibstaticd.lib
    copy Release\zlib.dll C:\thirdparty\vs2015\x64\zlib-1.2.11\bin\zlib.dll
    copy Release\zlib.exp C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlib.exp
    copy Release\zlib.lib C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlib.lib
    copy Release\zlibstatic.lib C:\thirdparty\vs2015\x64\zlib-1.2.11\lib\zlibstatic.lib
    copy zconf.h C:\thirdparty\vs2015\x64\zlib-1.2.11\zconf.h
    

    You can also download these scripts from https://github.com/Vertexwahn/Percdems