From eac7322832809ce66853518426f74044eb89fb11 Mon Sep 17 00:00:00 2001 From: shenwei41 Date: Sat, 13 Nov 2021 16:33:13 +0800 Subject: [PATCH] fix compilation bug --- ...f_copy_assignment_operators_with_GCC.patch | 109 ++++++++++++++++++ opencv.spec | 6 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 Fix_compilation_of_copy_assignment_operators_with_GCC.patch diff --git a/Fix_compilation_of_copy_assignment_operators_with_GCC.patch b/Fix_compilation_of_copy_assignment_operators_with_GCC.patch new file mode 100644 index 0000000..4d6a48c --- /dev/null +++ b/Fix_compilation_of_copy_assignment_operators_with_GCC.patch @@ -0,0 +1,109 @@ +diff -Npur opencv-4.5.2/modules/core/include/opencv2/core/types.hpp opencv-4.5.2-new/modules/core/include/opencv2/core/types.hpp +--- opencv-4.5.2/modules/core/include/opencv2/core/types.hpp 2021-04-02 19:23:54.000000000 +0800 ++++ opencv-4.5.2-new/modules/core/include/opencv2/core/types.hpp 2021-11-13 16:24:25.592720089 +0800 +@@ -162,13 +162,23 @@ public: + //! default constructor + Point_(); + Point_(_Tp _x, _Tp _y); ++#if (defined(__GNUC__) && __GNUC__ < 5) ++ Point_(const Point_& pt); ++ Point_(Point_&& pt) CV_NOEXCEPT = default; ++#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_(const Point_& pt); + Point_(Point_&& pt) CV_NOEXCEPT; ++#endif + Point_(const Size_<_Tp>& sz); + Point_(const Vec<_Tp, 2>& v); + ++#if (defined(__GNUC__) && __GNUC__ < 5) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 ++ Point_& operator = (const Point_& pt); ++ Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; ++#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_& operator = (const Point_& pt); + Point_& operator = (Point_&& pt) CV_NOEXCEPT; ++#endif + //! conversion to another data type + template operator Point_<_Tp2>() const; + +@@ -244,13 +254,17 @@ public: + //! default constructor + Point3_(); + Point3_(_Tp _x, _Tp _y, _Tp _z); ++#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_(const Point3_& pt); + Point3_(Point3_&& pt) CV_NOEXCEPT; ++#endif + explicit Point3_(const Point_<_Tp>& pt); + Point3_(const Vec<_Tp, 3>& v); + ++#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_& operator = (const Point3_& pt); + Point3_& operator = (Point3_&& pt) CV_NOEXCEPT; ++#endif + //! conversion to another data type + template operator Point3_<_Tp2>() const; + //! conversion to cv::Vec<> +@@ -320,12 +334,16 @@ public: + //! default constructor + Size_(); + Size_(_Tp _width, _Tp _height); ++#if OPENCV_ABI_COMPATIBILITY < 500 + Size_(const Size_& sz); + Size_(Size_&& sz) CV_NOEXCEPT; ++#endif + Size_(const Point_<_Tp>& pt); + ++#if OPENCV_ABI_COMPATIBILITY < 500 + Size_& operator = (const Size_& sz); + Size_& operator = (Size_&& sz) CV_NOEXCEPT; ++#endif + //! the area (width*height) + _Tp area() const; + //! aspect ratio (width/height) +@@ -425,13 +443,17 @@ public: + //! default constructor + Rect_(); + Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); ++#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_(const Rect_& r); + Rect_(Rect_&& r) CV_NOEXCEPT; ++#endif + Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz); + Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2); + ++#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_& operator = ( const Rect_& r ); + Rect_& operator = ( Rect_&& r ) CV_NOEXCEPT; ++#endif + //! the top-left corner + Point_<_Tp> tl() const; + //! the bottom-right corner +@@ -1164,6 +1186,12 @@ template inline + Point_<_Tp>::Point_(_Tp _x, _Tp _y) + : x(_x), y(_y) {} + ++#if (defined(__GNUC__) && __GNUC__ < 5) ++template inline ++Point_<_Tp>::Point_(const Point_& pt) ++ : x(pt.x), y(pt.y) {} ++#endif ++ + template inline + Point_<_Tp>::Point_(const Point_& pt) + : x(pt.x), y(pt.y) {} +@@ -1180,6 +1208,15 @@ template inline + Point_<_Tp>::Point_(const Vec<_Tp,2>& v) + : x(v[0]), y(v[1]) {} + ++#if (defined(__GNUC__) && __GNUC__ < 5) ++template inline ++Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) ++{ ++ x = pt.x; y = pt.y; ++ return *this; ++} ++#endif ++ + template inline + Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) + { diff --git a/opencv.spec b/opencv.spec index b9f8ce1..541c7e6 100644 --- a/opencv.spec +++ b/opencv.spec @@ -1,6 +1,6 @@ Name: opencv Version: 4.5.2 -Release: 2 +Release: 3 Summary: OpenCV means IntelĀ® Open Source Computer Vision Library. License: Apache-2.0 URL: https://github.com/opencv/opencv @@ -12,6 +12,7 @@ Source4: opencv_extra-4.5.2.tar.gz.ac Source5: opencv_extra-4.5.2.tar.gz.ad Source6: opencv_extra-4.5.2.tar.gz.ae Patch1: Fix-OpenCV-build-with-OpenEXR-before-2.2.0.patch +Patch2: Fix_compilation_of_copy_assignment_operators_with_GCC.patch BuildRequires: gcc-c++ gcc autoconf pkgconfig protobuf-compiler protobuf BuildRequires: cmake BuildRequires: libjpeg-devel @@ -75,6 +76,9 @@ make install DESTDIR=%{buildroot} %exclude /usr/local/share/* %changelog +* Wed Nov 13 2021 shenwei - 4.5.2-3 +- fix compilation of copy ctors/assignment operators with GCC 4.x + * Wed Nov 10 2021 yanhailiang - 4.5.2-2 - bugFix OpenCV build with OpenEXR before 2.2.0 -- Gitee