-
Notifications
You must be signed in to change notification settings - Fork 798
Description
Please if you have successfully built - provide suggestions here
Problem:
When attempting to build the project using Microsoft Visual Studio 2022 (MSVC 14.43) with the default C++17 standard (because I couldn't find Download Visual Studio Express 2013 for Windows Desktop to follow as done in the official windows installation instruction here), the build fails during compilation of OpenEXR (a third-party dependency bundled in OpenCV) due to the use of std::binary_function, which has been removed from the C++ standard since C++17. Even when forcing the build to use C++14 via -DCMAKE_CXX_STANDARD=14, the build still fails, suggesting that the compiler or build chain is not honoring the standard override or that other flags are conflicting.
Build Log Snippet:
[ 23%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfAttribute.cpp.obj
ImfAttribute.cpp
..\..\..\3rdparty\openexr\IlmImf\ImfAttribute.cpp(64): error C2039: 'binary_function': is not a member of 'std'
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\map(24): note: see declaration of 'std'
..\..\..\3rdparty\openexr\IlmImf\ImfAttribute.cpp(64): error C2504: 'binary_function': base class undefined
..\..\..\3rdparty\openexr\IlmImf\ImfAttribute.cpp(64): error C2143: syntax error: missing ',' before '<'
NMAKE : fatal error U1077: '...cl.exe' : return code '0x2'
Stop.
Cause:
The following line is responsible for the issue:
class AttributeTypeNameCompare : public std::binary_function<const char *, const char *, bool>
std::binary_function was deprecated in C++11 and completely removed in C++17, and appears to be unsupported even when attempting to enforce C++14 in this build context.
Attempted Workaround:
Tried:
cmake -DCMAKE_CXX_STANDARD=14 ..
But it did not resolve the issue — compilation still fails.
Proposed Fix:
Modernize the AttributeTypeNameCompare class by removing inheritance from std::binary_function and using a standard function object pattern:
class AttributeTypeNameCompare
{
public:
bool operator()(const char *x, const char *y) const
{
return std::strcmp(x, y) < 0;
}
};
Environment:
OS: Windows 11 Pro
Compiler: MSVC 14.43 (Visual Studio 2022)
CMake version: CMake 3.0.2
OpenEXR version: 3rdparty in OpenCV]
Build system: nmake