如何使用Visual Studio 14 2015 x64构建OpenEXR 2.2?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用Visual Studio 14 2015 x64构建OpenEXR 2.2?相关的知识,希望对你有一定的参考价值。
我正在使用CMake 3.7.1。我想使用Visual Studio 2015 x64构建OpenEXR 2.2。发行版包含详细的构建说明:
- 启动命令窗口,使用CMakeLists.txt导航到IlmBase文件夹,然后键入command:setlocal del / f CMakeCache.txt cmake -DCMAKE_INSTALL_PREFIX = -G“Visual Studio 10 Win64”.. ilmbase
- 导航到Windows资源管理器中的IlmBase文件夹,打开ILMBase.sln并构建解决方案。成功构建后,右键单击INSTALL项目并构建。它会将输出安装到您在上一步中设置的路径。
- 转到http://www.zlib.net并下载zlib
- 启动命令窗口,使用CMakeLists.txt导航到OpenEXR文件夹,然后键入command:setlocal del / f CMakeCache.txt cmake -DZLIB_ROOT = -DILMBASE_PACKAGE_PREFIX = -DCMAKE_INSTALL_PREFIX = -G“Visual Studio 10 Win64”^ .. openexr
- 在Windows资源管理器中导航到OpenEXR文件夹,打开OpenEXR.sln并构建解决方案。成功构建后,右键单击INSTALL项目并构建。它会将输出安装到您在上一步中设置的路径。
第1步到第2步对我来说没有问题。 IlmBase的lib,dll和头文件存储在“build”文件夹中:
我执行了第1步到第2步的说明:
wget.exe https://github.com/openexr/openexr/archive/v2.2.0.zip -OC: hirdpartyvs2015x64openexr-2.2.0.zip
7za.exe x C: hirdpartyvs2015x64openexr-2.2.0.zip -oC: hirdpartyvs2015x64
del C: hirdpartyvs2015x64openexr-2.2.0.zip
C:
cd C: hirdpartyvs2015x64openexr-2.2.0IlmBase
cmake -G"Visual Studio 14 2015 Win64" -HC: hirdpartyvs2015x64openexr-2.2.0 -BC:uildvs2015x64openexr-2.2.0 ^
setlocal
del /f CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX="..ilmbaseuild" -G "Visual Studio 14 2015 Win64" ..ilmbase
cmake --build . --config Release
cmake --build . --config Debug
cmake --build . --target INSTALL
第3步(下载并构建zlib-1.2.8)也很简单:
wget.exe http://zlib.net/zlib128.zip -OC: hirdpartyvs2015x64zlib-1.2.8.zip
7za.exe x C: hirdpartyvs2015x64zlib-1.2.8.zip -oC: hirdpartyvs2015x64
del C: hirdpartyvs2015x64zlib-1.2.8.zip
call "C:Program Files (x86)Microsoft Visual Studio 14.0VCvcvarsall.bat" amd64
cmake -G"Visual Studio 14 2015 Win64" -HC: hirdpartyvs2015x64zlib-1.2.8 -BC:uildvs2015x64zlib-1.2.8
C:
cd C:uildvs2015x64zlib-1.2.8
cmake --build . --config Release
cmake --build . --config Debug
mkdir C: hirdpartyvs2015x64zlib-1.2.8lib
mkdir C: hirdpartyvs2015x64zlib-1.2.8in
copy Debugzlibd.dll C: hirdpartyvs2015x64zlib-1.2.8inzlibd.dll
copy Debugzlibd.exp C: hirdpartyvs2015x64zlib-1.2.8libzlibd.exp
copy Debugzlibd.ilk C: hirdpartyvs2015x64zlib-1.2.8libzlibd.ilk
copy Debugzlibd.lib C: hirdpartyvs2015x64zlib-1.2.8libzlibd.lib
copy Debugzlibd.pdb C: hirdpartyvs2015x64zlib-1.2.8libzlibd.pdb
copy Debugzlibstaticd.lib C: hirdpartyvs2015x64zlib-1.2.8libzlibstaticd.lib
copy Releasezlib.dll C: hirdpartyvs2015x64zlib-1.2.8inzlib.dll
copy Releasezlib.exp C: hirdpartyvs2015x64zlib-1.2.8libzlib.exp
copy Releasezlib.lib C: hirdpartyvs2015x64zlib-1.2.8libzlib.lib
copy Releasezlibstatic.lib C: hirdpartyvs2015x64zlib-1.2.8libzlibstatic.lib
cd C: hirdpartyvs2015x64
rmdir C:uildvs2015x64zlib-1.2.8 /S /Q
现在谈到第4 + 5步。我正在执行以下语句:
cmake -DZLIB_ROOT="C: hirdpartyvs2015x64zlib-1.2.8" ^
-DILMBASE_PACKAGE_PREFIX="C: hirdpartyvs2015x64openexr-2.2.0IlmBaseuild" ^
-DCMAKE_INSTALL_PREFIX="..OpenEXRuild" ^
-G "Visual Studio 14 2015 Win64" ^
..openexr
我打开openexr.sln,而不是尝试构建IlmInf。有一个错误:“cmd.exe”已退出,代码为-1073741515
这是错误日志:
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: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfCMakeFilesgenerate.stamp is up-to-date.
4> Generating b44ExpLogTable.h
4>C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code -1073741515.
========== Build: 3 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我不明白为什么我会收到这个错误。我在这做错了什么?
BTW:我可以在这里找到用于构建zlib和OpenEXR的批处理脚本:https://bitbucket.org/snippets/Vertexwahn/
IlmImf尝试运行b44ExpLogTable.exe,它需要位于正确位置的Half.dll文件。将Half.dll等文件复制到正确的位置时一切正常。
我使用以下Windows批处理脚本来处理构建OpenEXR并将所有内容复制到正确的位置:
Build_openexr-2.2.0_Visual Studio 14 2015 Win64.cmd
wget.exe https://github.com/openexr/openexr/archive/v2.2.0.zip -OC: hirdpartyvs2015x64openexr-2.2.0.zip
7za.exe x C: hirdpartyvs2015x64openexr-2.2.0.zip -oC: hirdpartyvs2015x64
del C: hirdpartyvs2015x64openexr-2.2.0.zip
C:
cd C: hirdpartyvs2015x64openexr-2.2.0IlmBase
cmake -DCMAKE_INSTALL_PREFIX="C: hirdpartyvs2015x64openexr-2.2.0deploy" ^
-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: hirdpartyvs2015x64openexr-2.2.0OpenEXR
setlocal
del /f CMakeCache.txt
cmake -DZLIB_ROOT="C: hirdpartyvs2015x64zlib-1.2.11" ^
-DILMBASE_PACKAGE_PREFIX="C: hirdpartyvs2015x64openexr-2.2.0deploy" ^
-DCMAKE_INSTALL_PREFIX="..deploy" ^
-G "Visual Studio 14 2015 Win64" ^
..openexr
mkdir C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelease
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibHalf.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfReleaseHalf.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIex-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfReleaseIex-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIexMath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfReleaseIexMath.2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIlmThread-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfReleaseIlmThread-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibImath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfReleaseImath-2_2.dll
mkdir C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfo
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibHalf.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfoHalf.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIex-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfoIex-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIexMath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfoIexMath.2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIlmThread-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfoIlmThread-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibImath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfRelWithDebInfoImath-2_2.dll
mkdir C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebug
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibHalf.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebugHalf.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIex-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebugIex-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIexMath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebugIexMath.2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibIlmThread-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebugIlmThread-2_2.dll
copy C: hirdpartyvs2015x64openexr-2.2.0deploylibImath-2_2.dll C: hirdpartyvs2015x64openexr-2.2.0OpenEXRIlmImfDebugImath-2_2.dll
cmake --build . --config Release
cmake --build . --config RelWithDebInfo
cmake --build . --config Debug
cmake --build . --target INSTALL
构建OpenEXR需要预构建zlib版本。我使用以下脚本构建zlib:
Build_zlib-1.2.11_Visual Studio 14 2015 Win64.cmd
wget.exe http://zlib.net/zlib1211.zip -OC: hirdpartyvs2015x64zlib-1.2.11.zip
7za.exe x C: hirdpartyvs2015x64zlib-1.2.11.zip -oC: hirdpartyvs2015x64
del C: hirdpartyvs2015x64zlib-1.2.11.zip
call "C:Program Files (x86)Microsoft Visual Studio 14.0VCvcvarsall.bat" amd64
cmake -G"Visual Studio 14 2015 Win64" -HC: hirdpartyvs2015x64zlib-1.2.11 -BC: hirdpartyvs2015x64zlib-1.2.11uild
C:
cd C: hirdpartyvs2015x64zlib-1.2.11uild
cmake --build . --config Debug
cmake --build . --config Release
cmake --build . --config RelWithDebInfo
mkdir C: hirdpartyvs2015x64zlib-1.2.11lib
mkdir C: hirdpartyvs2015x64zlib-1.2.11in
copy Debugzlibd.dll C: hirdpartyvs2015x64zlib-1.2.11inzlibd.dll
copy Debugzlibd.exp C: hirdpartyvs2015x64zlib-1.2.11libzlibd.exp
copy Debugzlibd.ilk C: hirdpartyvs2015x64zlib-1.2.11libzlibd.ilk
copy Debugzlibd.lib C: hirdpartyvs2015x64zlib-1.2.11libzlibd.lib
copy Debugzlibd.pdb C: hirdpartyvs2015x64zlib-1.2.11libzlibd.pdb
copy Debugzlibstaticd.lib C: hirdpartyvs2015x64zlib-1.2.11libzlibstaticd.lib
copy Releasezlib.dll C: hirdpartyvs2015x64zlib-1.2.11inzlib.dll
copy Releasezlib.exp C: hirdpartyvs2015x64zlib-1.2.11libzlib.exp
copy Releasezlib.lib C: hirdpartyvs2015x64zlib-1.2.11libzlib.lib
copy Releasezlibstatic.lib C: hirdpartyvs2015x64zlib-1.2.11libzlibstatic.lib
copy zconf.h C: hirdpartyvs2015x64zlib-1.2.11zconf.h
您也可以从https://bitbucket.org/Vertexwahn/percdems下载这些脚本
修复错误MSB6006“cmd.exe”的步骤:
- 确保你已经构建了ilmbase.sln解决方案,之后构建了ilmbase的“INSTALL”部分。结果你会找到lib并在ilmbase目录中包含文件夹。
- 打开高级系统设置和路径... ilmbase-2.2.0 lib;到“Path”系统变量的末尾。关闭高级系统设置。
- 重新启动Visual Studio并重建openexr.sln
接受的答案对我来说不适用于OpenEXR 2.3.0。下面是一个批处理文件,适用于Windows 10和VS 2015 x64。您需要wget.exe,7za.exe以及同一文件夹中以下批处理的内容。请注意,我已经禁用了Python库,因为我不需要它们,而且我没有安装Python。
rem ### ZLIB ###
wget.exe http://zlib.net/zlib1211.zip -O.zlib-1.2.11.zip
7za.exe x .zlib-1.2.11.zip -o.
del .zlib-1.2.11.zip
call "C:Program Files (x86)Microsoft Visual Studio 14.0VCvcvarsall.bat" amd64
cmake -G"Visual Studio 14 2015 Win64" -H.zlib-1.2.11 -B.zlib-1.2.11uild
cd zlib-1.2.11uild
cmake --build . --config Debug
cmake --build . --config Release
cmake --build . --config RelWithDebInfo
cd..
mkdir lib
mkdir bin
cd build
copy Debugzlibd.dll ..inzlibd.dll
copy Debugzlibd.exp ..libzlibd.exp
copy Debugzlibd.ilk ..libzlibd.ilk
copy Debugzlibd.lib ..libzlibd.lib
copy Debugzlibd.pdb ..libzlibd.pdb
copy Debugzlibstaticd.lib ..libzlibstaticd.lib
copy Releasezlib.dll ..inzlib.dll
copy Releasezlib.exp ..libzlib.exp
copy Releasezlib.lib ..libzlib.lib
copy Releasezlibstatic.lib ..libzlibstatic.lib
copy zconf.h ..zconf.h
cd....
rem ### OPENEXR ###
wget.exe https://github.com/openexr/openexr/archive/v2.3.0.zip -O.openexr-2.3.0.zip
7za.exe x .openexr-2.3.0.zip -o.
del .openexr-2.3.0.zip
cd openexr-2.3.0
setlocal
del /f CMakeCache.txt
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="%~dp0openexr-2.3.0" -DCMAKE_PREFIX_PATH="%~dp0zlib-1.2.11" -DOPENEXR_BUILD_PYTHON_LIBS=0
cmake --build . --target INSTALL --config Debug -- /maxcpucount:8
cmake --build . --target INSTALL --config Release -- /maxcpucount:8
cmake --build . --target INSTALL --config RelWithDebInfo -- /maxcpucount:8
pause
在OpenEXR 2.3.0上似乎有一个带有IlmImf CMake文件的open issue。
建议的解决方法(搜索和替换OPENEXR_PACKAGE_PREFIX
与CMAKE_INSTALL_PREFIX
)在我的情况下工作正常。
在我的情况下,我只是打电话
sed -i "s/OPENEXR_PACKAGE_PREFIX/CMAKE_INSTALL_PREFIX/g" ./OpenEXR/IlmImf/CMakeLists.txt
在运行cmake
之前(git for windows)
以上是关于如何使用Visual Studio 14 2015 x64构建OpenEXR 2.2?的主要内容,如果未能解决你的问题,请参考以下文章
安装 Visual Studio 2015 企业版是不是足以使用 C++11/C++14?
如何设置[ZeroMQ]以在Visual Studio 2015 Enterprise中使用?
加载 Visual Studio 2015 C++ 项目时出错,如何调试