「利用者:Jehuty/GSoC 2013/Discussions/Compiling OpenVDB」の版間の差分

提供: wiki
移動先: 案内検索
(Compiling OpenVDB)
 
(1版 をインポートしました)
 
(相違点なし)

2018年6月29日 (金) 05:56時点における最新版

Compiling OpenVDB

These were the steps taken to add the OpenVDB library to the Blender solution in the Cycles Volume branch.

I used MSVS 2008 on Windows 7 and built for 32-bit.

Branch: soc-2013-cycles_volume (https://svn.blender.org/svnroot/bf-blender/branches/soc-2013-cycles_volume)

I used the OpenVDB library version 1.1.1 (http://www.openvdb.org/download/ - latest version only), but also available from their github repository (https://github.com/dreamworksanimation/openvdb_dev).

As per its makefile, only the needed files were added to extern/openvdb, which meant excluding the folders cmd, doc and unittest.

The needed dependencies are:

* Boost (www.boost.org), version 1.42.0 or later
* libz (zlib.net)
* OpenEXR (www.openexr.com), for the 16-bit float Half class in half.h
* Intel Threading Building Blocks (threadingbuildingblocks.org),
 version 3.0 or later

Blender has the first three available in trunk/lib/ (for MSVS2008 on Windows, 32-bit: https://svn.blender.org/svnroot/bf-blender/trunk/lib/windows).

I downloaded tbb41_20130613oss_win.zip from Intel's tbb website, and extracted the folders include and lib\ia32\vc9 to lib\windows\tbb\include and lib\windows\tbb\lib, respectively. This helped keep the libs directory organized, even though tbb hasn't been added to svn at this time.

With everything in place, hit Build, and voilá, nothing works. Quite the contrary. I kept getting this error:

1>------ Build started: Project: extern_openvdb, Configuration: Debug Win32 ------
1>Compiling...
1>Archive.cc
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(38) : error C2065: 'numeric_limits' : undeclared identifier
1>        r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(44) : see reference to class template instantiation 'boost::numeric::convdetail::get_int_float_mixture<T,S>' being compiled
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(38) : error C2975: 'C_' : invalid template argument for 'boost::mpl::bool_', expected compile-time constant expression
1>        r:\blender\blendersvn\lib\windows\boost\include\boost\mpl\bool.hpp(23) : see declaration of 'C_'
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(38) : error C2143: syntax error : missing ';' before '>'
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(38) : error C2238: unexpected token(s) preceding ';'
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(39) : error C2065: 'numeric_limits' : undeclared identifier
1>r:\blender\blendersvn\lib\windows\boost\include\boost\numeric\conversion\detail\int_float_mixture.hpp(39) : error C2975: 'C_' : invalid template argument for 'boost::mpl::bool_', expected compile-time constant expression

and it went on and on with similar errors for each file. At first, I thought boost header files weren't being included correctly, since I was using CMake to setup the project.

So I added a project manually to the CMake-generated Blender solution file, configured the correct directories in Additional Include Directories in this new project's settings, and tried compiling it - same errors, meaning CMake was not to blame.

After going through numerous trial and error attempts, I found a post by Joe Kider on OpenVDB's forum that led me to the solution.

First, there is this precious bit of advice from http://www.winimage.com/zLibDll/index.html :

Blender3D FreeTip.png
zlib
Make sure to define _WINDOWS and ZLIB_DLL before including zlib.h.


This led to adding #define ZLIB_WINAPI to the file extern\openvdb\internal\openvdb\io\Compression.cc;

Secondly, from this article on Microsoft Support: http://support.microsoft.com/kb/143208, we have

Blender3D FreeTip.png
std::min & std::max
Simply define the NOMINMAX preprocessor symbol. This can be done in the Developer Studio project under Build, Settings, on the C/C++ tab, in the Preprocessor category. This will suppress the min and max definitions in Windef.h.


Then I added #define NOMINMAX to the file extern\openvdb\internal\openvdb\math\Coord.h;

After both changes, the library compiled regardless of how it was added, manually or setup by CMake.

Since both workarounds are platform-specific, I'll add platform guards around these.