Closed vndroid closed 1 year ago
OpenCV version: 2.4.13.7 - it very old version. I was release many years before C++17 and is not supported by OpenCV team. Please use modern Library version (3.4.19 or 4.7.0).
OpenCV version: 2.4.13.7 - it very old version. I was release many years before C++17 and is not supported by OpenCV team. Please use modern Library version (3.4.19 or 4.7.0).
Yep, I already know it is too old, but I use it to build the VideoLAN, the 3.x and 4.x opencv can not be used in the vlc.
@vndroid you won't need HDR images support for VideoLan, so try to use
-DWITH_OPENEXR=OFF -DBUILD_OPENEXR=OFF
cmake flags , to disable it
Another possibility is to tell GCC to compile with the C++98 Standard via CMAKE options.
cmake ../ -DCMAKE_CXX_STANDARD=98 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSION=OFF
make -j 12
These CMAKE parametes request upper CMake 3.1.
OpenCV 4.x uses these parameters to apply C++11.
Hi! I were able to compile VLC with the latest OpenCV and the following changes. Note that I have not tested how it works yet.
--- a/modules/core/include/opencv2/core/cvdef.h
+++ b/modules/core/include/opencv2/core/cvdef.h
@@ -778,14 +778,16 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
# undef CV_CXX11
# endif
#endif
-#ifndef CV_CXX11
+#if defined(__cplusplus) && !defined(CV_CXX11)
# error "OpenCV 4.x+ requires enabled C++11 support"
#endif
+#ifdef __cplusplus
#define CV_CXX_MOVE_SEMANTICS 1
#define CV_CXX_MOVE(x) std::move(x)
#define CV_CXX_STD_ARRAY 1
#include <array>
+#endif
#ifndef CV_OVERRIDE
# define CV_OVERRIDE override
#endif
VLC patch:
--- a/configure.ac
+++ b/configure.ac
@@ -2069,7 +2069,7 @@ PKG_ENABLE_MODULES_VLC([BLURAY], [libbluray], [libbluray >= 0.6.2], (libbluray f
dnl
dnl OpenCV wrapper and example filters
dnl
-PKG_ENABLE_MODULES_VLC([OPENCV], [opencv_example opencv_wrapper], [opencv > 2.0], (OpenCV (computer vision) filter), [auto])
+PKG_ENABLE_MODULES_VLC([OPENCV], [opencv_example opencv_wrapper], [opencv4], (OpenCV (computer vision) filter), [auto])
@opencv-alalek, @mshabunin, what is your opinion about this workaround?
I'm trying to understand on this minimal example:
// main.c
#include <opencv2/core/core_c.h>
int main(int argc, char** argv) {
CvMat* inp = cvCreateMatHeader(256 * 256, 1, CV_32FC2);
CvMat* out = cvCreateMatHeader(256 * 256, 1, CV_32FC2);
cvCreateData(inp);
cvCreateData(out);
cvDFT(inp, out, CV_DXT_FORWARD, 0);
cvReleaseData(inp);
cvReleaseData(out);
return 0;
}
If I compile with one of the following flags, there is an error:
gcc main.c -o app -I/home/dkurt/opencv_install/include/opencv4/ -lopencv_core -L/home/dkurt/opencv_install/lib/
gcc main.c -o app -I/home/dkurt/opencv_install/include/opencv4/ -lopencv_core -L/home/dkurt/opencv_install/lib/ -O2
In file included from /home/dkurt/opencv_install/include/opencv4/opencv2/core/types_c.h:84,
from /home/dkurt/opencv_install/include/opencv4/opencv2/core/core_c.h:48,
from main.c:1:
/home/dkurt/opencv_install/include/opencv4/opencv2/core/cvdef.h:783:4: error: #error "OpenCV 4.x+ requires enabled C++11 support"
783 | # error "OpenCV 4.x+ requires enabled C++11 support"
| ^~~~~
/home/dkurt/opencv_install/include/opencv4/opencv2/core/cvdef.h:790:10: fatal error: array: No such file or directory
790 | #include <array>
| ^~~~~~~
compilation terminated.
However with this patch and -O2
I'm able to compile and run the app.
--- a/modules/core/include/opencv2/core/cvdef.h
+++ b/modules/core/include/opencv2/core/cvdef.h
@@ -778,14 +778,16 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
# undef CV_CXX11
# endif
#endif
-#ifndef CV_CXX11
+#if defined(__cplusplus) && !defined(CV_CXX11)
# error "OpenCV 4.x+ requires enabled C++11 support"
#endif
+#ifdef __cplusplus
#define CV_CXX_MOVE_SEMANTICS 1
#define CV_CXX_MOVE(x) std::move(x)
#define CV_CXX_STD_ARRAY 1
#include <array>
+#endif
#ifndef CV_OVERRIDE
# define CV_OVERRIDE override
#endif
I don't understand why there is a difference in adding -O2
:
$ gcc main.c -o app -I/home/dkurt/opencv_install/include/opencv4/ -lopencv_core -L/home/dkurt/opencv_install/lib/
/usr/local/bin/ld: /tmp/ccwyTyeQ.o: undefined reference to symbol 'lrint@@GLIBC_2.2.5'
/usr/local/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
UPD: Even with -O1
it's compiled fine. GCC 9.4.0 (Ubuntu 20.04)
some problem which sounds similar: https://stackoverflow.com/questions/30514416/gcc-links-to-wrong-glibcxx-version-when-o2-flag-is-specified
UPD: related MR in VLC: https://code.videolan.org/videolan/vlc/-/merge_requests/927
System Information
OpenCV version: 2.4.13.7 Operating System / Platform: Ubuntu 22.04 Compiler & compiler version: GCC 11.3.0
Detailed description
Build log
the error is similar, such as
Steps to reproduce
according to the official doc: opencv
Can see some warning info:
edit the CMake file (## line is comment)
Issue submission checklist