Skip to content

build (5.x): system OpenEXR may cause build failure due to switching to C++17 #26673

@fengyuentau

Description

@fengyuentau

System Information

latest 5.x

Detailed description

One of my boards come with customized Ubuntu and OpenEXR 2.2.1 is installed in it. Try to clone and build OpenCV 5 on the board, but got something as follows:

# ...
/usr/include/OpenEXR/ImathMatrix.h:643:25: error: ISO C++17 does not allow dynamic exception specifications
                         throw (IEX_NAMESPACE::MathExc);
                         ^~~~~
/usr/include/OpenEXR/ImathMatrix.h:646:25: error: ISO C++17 does not allow dynamic exception specifications
                         throw (IEX_NAMESPACE::MathExc);
                         ^~~~~
/usr/include/OpenEXR/ImathMatrix.h:649:25: error: ISO C++17 does not allow dynamic exception specifications
                         throw (IEX_NAMESPACE::MathExc);
                         ^~~~~
/usr/include/OpenEXR/ImathMatrix.h:1433:38: error: ISO C++17 does not allow dynamic exception specifications
 Matrix33<T>::gjInvert (bool singExc) throw (IEX_NAMESPACE::MathExc)
                                      ^~~~~
/usr/include/OpenEXR/ImathMatrix.h:1441:45: error: ISO C++17 does not allow dynamic exception specifications
 Matrix33<T>::gjInverse (bool singExc) const throw (IEX_NAMESPACE::MathExc)
                                             ^~~~~
/usr/include/OpenEXR/ImathMatrix.h:1545:36: error: ISO C++17 does not allow dynamic exception specifications
 Matrix33<T>::invert (bool singExc) throw (IEX_NAMESPACE::MathExc)
                                    ^~~~~
# ...

Possible solution:

From the release history log of OpenEXR, this issue has been solved since 2.3.0, which is the exact version in opencv/3rdparty. Tested with -DBUILD_OPENEXR=ON and it worked fine. We should detect OpenEXR version in our CMake script and turn to use the integrated one when the version of system one is below that.

Steps to reproduce

  1. Install OpenEXR < 2.3.0.
  2. Clone OpenCV 5 and build.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions