AcademySoftwareFoundation / OpenImageIO

Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.
https://openimageio.readthedocs.org
Apache License 2.0
1.97k stars 597 forks source link

[BUILD] Support OpenVDB 10.1 #4021

Closed MehdiChinoune closed 1 year ago

MehdiChinoune commented 1 year ago

Fails to build against OpenVDB 10.1.0 (Build fine against 10.0.1).

  [104/166] Building CXX object src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/__/openvdb.imageio/openvdbinput.cpp.obj
  FAILED: src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/__/openvdb.imageio/openvdbinput.cpp.obj 
  D:\M\msys64\mingw64\bin\g++.exe -DEMBED_PLUGINS=1 -DIMATH_DLL -DOIIO_FFMPEG_VERSION=\"6.0\" -DOIIO_INTERNAL=1 -DOIIO_OPENEXR_CORE_DEFAULT=1 -DOIIO_USE_EXR_C_API=1 -DOPENEXR_DLL -DOpenImageIO_EXPORTS -DUSE_BOOST_FILESYSTEM -DUSE_DCMTK=1 -DUSE_EXTERNAL_PUGIXML=1 -DUSE_FFMPEG -DUSE_FREETYPE=1 -DUSE_GIF -DUSE_HEIF=1 -DUSE_JPEG_TURBO=1 -DUSE_LIBRAW=1 -DUSE_OCIO=1 -DUSE_OPENCOLORIO=1 -DUSE_OPENCV=1 -DUSE_OPENJPEG -DUSE_OPENVDB=1 -DUSE_PTEX -DUSE_WEBP=1 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -IC:/_/B/src/build-MINGW64/include/OpenImageIO -IC:/_/B/src/build-MINGW64/include -IC:/_/B/src/build-MINGW64/src/include -IC:/_/B/src/OpenImageIO-2.5.4.0/src/include -ID:/M/msys64/mingw64/include/openjpeg-2.5 -I/OpenEXR -ID:/M/msys64/mingw64/include/freetype2 -isystem D:/M/msys64/mingw64/include/opencv4 -isystem D:/M/msys64/mingw64/include/Imath -isystem D:/M/msys64/mingw64/include/OpenEXR -march=nocona -msahf -mtune=generic -O2 -pipe -O3 -DNDEBUG -std=c++14 -fvisibility=hidden -Wall -Wno-unused-local-typedefs -Wno-unused-result -Wno-aligned-new -Wno-noexcept-type -fno-math-errno -MD -MT src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/__/openvdb.imageio/openvdbinput.cpp.obj -MF src\libOpenImageIO\CMakeFiles\OpenImageIO.dir\__\openvdb.imageio\openvdbinput.cpp.obj.d -o src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/__/openvdb.imageio/openvdbinput.cpp.obj -c C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp
  In file included from D:/M/msys64/mingw64/include/openvdb/Types.h:9,
                   from D:/M/msys64/mingw64/include/openvdb/openvdb.h:8,
                   from C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp:14:
  D:/M/msys64/mingw64/include/openvdb/TypeList.h: In member function 'constexpr auto openvdb::v10_1::TupleList<Ts>::size()':
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:41: error: 'tuple_size_v' is not a member of 'std'
    858 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                         ^~~~~~~~~~~~
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:41: note: 'std::tuple_size_v' is only available from C++17 onwards
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:60: error: expected primary-expression before '>' token
    858 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                                            ^
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:61: error: expected primary-expression before ';' token
    858 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                                             ^
  D:/M/msys64/mingw64/include/openvdb/TypeList.h: In member function 'constexpr auto openvdb::v10_1::TupleList<>::size()':
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:962:41: error: 'tuple_size_v' is not a member of 'std'
    962 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                         ^~~~~~~~~~~~
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:962:41: note: 'std::tuple_size_v' is only available from C++17 onwards
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:962:60: error: expected primary-expression before '>' token
    962 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                                            ^
  D:/M/msys64/mingw64/include/openvdb/TypeList.h:962:61: error: expected primary-expression before ';' token
    962 |     constexpr auto size() { return std::tuple_size_v<TupleT>; }
        |                                                             ^
  In file included from D:/M/msys64/mingw64/include/openvdb/tree/Tree.h:21,
                   from D:/M/msys64/mingw64/include/openvdb/Grid.h:12,
                   from D:/M/msys64/mingw64/include/openvdb/openvdb.h:13:
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h: In member function 'auto openvdb::v10_1::tree::ValueAccessorLock<MutexT>::lock() const':
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:313:44: error: 'scoped_lock' is not a member of 'std'
    313 |     inline auto lock() const { return std::scoped_lock(m); }
        |                                            ^~~~~~~~~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:313:44: note: 'std::scoped_lock' is only available from C++17 onwards
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h: In member function 'auto openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::evalFirstIndex(OpT&&) const':
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:977:36: error: 'invoke_result' in namespace 'std' does not name a template type
    977 |         using RetT = typename std::invoke_result<OpT, IndexT>::type;
        |                                    ^~~~~~~~~~~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:977:36: note: 'std::invoke_result' is only available from C++17 onwards
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:978:65: error: there are no arguments to 'RetT' that depend on a template parameter, so a declaration of 'RetT' must be available [-fpermissive]
    978 |         return openvdb::evalFirstIndex<0, NumCacheLevels+1>(op, RetT(NULL));
        |                                                                 ^~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:978:65: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h: In member function 'auto openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::evalFirstPred(PredT&&, OpT&&) const':
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:992:36: error: 'invoke_result' in namespace 'std' does not name a template type
    992 |         using RetT = typename std::invoke_result<OpT, RootNodeT*>::type;
        |                                    ^~~~~~~~~~~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:992:36: note: 'std::invoke_result' is only available from C++17 onwards
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:993:36: error: 'RetT' was not declared in this scope
    993 |         if constexpr(!std::is_same<RetT, void>::value) {
        |                                    ^~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:993:46: error: template argument 1 is invalid
    993 |         if constexpr(!std::is_same<RetT, void>::value) {
        |                                              ^
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h: In instantiation of 'auto openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::evalFirstIndex(OpT&&) const [with OpT = openvdb::v10_1::tree::ValueAccessorImpl<const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<float, 3>, 4>, 5> > >, true, void, openvdb::v10_1::index_sequence<0, 1, 2> >::getValue(const openvdb::v10_1::math::Coord&) const::<lambda(auto:3)>; _TreeType = const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<float, 3>, 4>, 5> > >; bool IsSafe = true; MutexT = void; IntegerSequence = openvdb::v10_1::index_sequence<0, 1, 2>]':
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:459:37:   required from 'const openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::ValueType& openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::getValue(const openvdb::v10_1::math::Coord&) const [with _TreeType = const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<float, 3>, 4>, 5> > >; bool IsSafe = true; MutexT = void; IntegerSequence = openvdb::v10_1::index_sequence<0, 1, 2>; ValueType = float]'
  C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp:224:43:   required from 'static bool OpenImageIO_v2_5::{anonymous}::VDBReader<GridType>::readTile(const GridType&, int, int, int, ValueType*) [with GridType = openvdb::v10_1::Grid<openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<float, 3>, 4>, 5> > > >; ValueType = float]'
  C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp:570:46:   required from here
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:978:69: error: 'RetT' was not declared in this scope
    978 |         return openvdb::evalFirstIndex<0, NumCacheLevels+1>(op, RetT(NULL));
        |                                                                 ~~~~^~~~~~
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h: In instantiation of 'auto openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::evalFirstIndex(OpT&&) const [with OpT = openvdb::v10_1::tree::ValueAccessorImpl<const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<openvdb::v10_1::math::Vec3<float>, 3>, 4>, 5> > >, true, void, openvdb::v10_1::index_sequence<0, 1, 2> >::getValue(const openvdb::v10_1::math::Coord&) const::<lambda(auto:3)>; _TreeType = const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<openvdb::v10_1::math::Vec3<float>, 3>, 4>, 5> > >; bool IsSafe = true; MutexT = void; IntegerSequence = openvdb::v10_1::index_sequence<0, 1, 2>]':
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:459:37:   required from 'const openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::ValueType& openvdb::v10_1::tree::ValueAccessorImpl<TreeType, IsSafe, MutexT, IndexSequence>::getValue(const openvdb::v10_1::math::Coord&) const [with _TreeType = const openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<openvdb::v10_1::math::Vec3<float>, 3>, 4>, 5> > >; bool IsSafe = true; MutexT = void; IntegerSequence = openvdb::v10_1::index_sequence<0, 1, 2>; ValueType = openvdb::v10_1::math::Vec3<float>]'
  C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp:224:43:   required from 'static bool OpenImageIO_v2_5::{anonymous}::VDBReader<GridType>::readTile(const GridType&, int, int, int, ValueType*) [with GridType = openvdb::v10_1::Grid<openvdb::v10_1::tree::Tree<openvdb::v10_1::tree::RootNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::InternalNode<openvdb::v10_1::tree::LeafNode<openvdb::v10_1::math::Vec3<float>, 3>, 4>, 5> > > >; ValueType = openvdb::v10_1::math::Vec3<float>]'
  C:/_/B/src/OpenImageIO-2.5.4.0/src/openvdb.imageio/openvdbinput.cpp:574:46:   required from here
  D:/M/msys64/mingw64/include/openvdb/tree/ValueAccessor.h:978:69: error: 'RetT' was not declared in this scope
ThiagoIze commented 1 year ago

The error message says: D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:41: note: 'std::tuple_size_v' is only available from C++17 onwards you are compiling with C++14. Tell your compiler to use C++17 and it will probably work. I think that's CMAKE_CXX_STANDARD=17

lgritz commented 1 year ago

Does OpenVDB 10.1 require a C++17 minimum?

MehdiChinoune commented 1 year ago

It buil

The error message says: D:/M/msys64/mingw64/include/openvdb/TypeList.h:858:41: note: 'std::tuple_size_v' is only available from C++17 onwards you are compiling with C++14. Tell your compiler to use C++17 and it will probably work. I think that's CMAKE_CXX_STANDARD=17

It works, Thanks. Still there is no mention of C++17 requirement in the release notes.

lgritz commented 1 year ago

Actually: https://github.com/AcademySoftwareFoundation/openvdb/blob/master/cmake/config/OpenVDBVersions.cmake#L17

I will make a PR for OIIO that gives appropriate warnings when building against an OpenVDB that's so new that it requires C++17.

lgritz commented 1 year ago

Yeah, looking at older versions of OpenVDB source, it looks like through 9.x, C++14 was adequate, but for OpenVDB >= 10.0, C++17 was their minimum.

MehdiChinoune commented 1 year ago

Yeah, looking at older versions of OpenVDB source, it looks like through 9.x, C++14 was adequate, but for OpenVDB >= 10.0, C++17 was their minimum.

It was building fine against 10.0.1, Maybe they started using C++17 features with 10.1.0

lgritz commented 1 year ago

To try to protect against this in the future: https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4023