Redeclaration issue [closed]
I'm trying to build OpenCV project (cpp) with following inclusions:
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui/highgui.hpp"
and getting an error during the make "redeclaration issues.
It happens because of imgcodecs.hpp contains declaration:
enum {
IMREAD_UNCHANGED = -1, // 8bit, color or not
IMREAD_GRAYSCALE = 0, // 8bit, gray
IMREAD_COLOR = 1, // ?, color
IMREAD_ANYDEPTH = 2, // any depth, ?
IMREAD_ANYCOLOR = 4, // ?, any color
IMREAD_LOAD_GDAL = 8 // Use gdal driver
};
And highgui.hpp contains basically the same:
enum {
// 8bit, color or not
IMREAD_UNCHANGED =-1,
// 8bit, gray
IMREAD_GRAYSCALE =0,
// ?, color
IMREAD_COLOR =1,
// any depth, ?
IMREAD_ANYDEPTH =2,
// ?, any color
IMREAD_ANYCOLOR =4
};
Is any way to fix it without changing hpp files of OpenCV?
I'm really newbie at c++ thus my question could be dummy (sorry for that)
which compiler/os ?
could you come up with a minimal test case proving it ?
i'm using cmake make combo.Ubuntu 14.04.
I found out that standard sample squares.cpp use the same combination on includes. Can't compile it either (with same error).
if you just could add the exact error ?
This can be solved by adding include guards only. Mentioned here for example. No way of avoiding this. Someone should make a PR!
^^ if i'm not missing something, there are include guards already
(and they would not help against duplicate enums in different headers in the same namespace).
but again, can't reproduce the error.
berak, thank you for pushing me in right direction. Once I installing opencv i've download and compile version form page http://opencv.org/downloads.html and it seems mistakes is there. Once I take git version all troubles disappeared. Thanks you a lot again.
well,now call me confused..
In the beginning I have downloaded 2 versions 2.4.10 - by link and git (which is actually 3 beta) I do not understand the difference for that moment. I have compiled both but 2.4.10 was in a second turn. But once I have try examples I took them from 3 beta - which clause the multiple errors.
for instance for 2.4.10: > include "opencv2/imgproc/imgproc.hpp" include "opencv2/highgui/highgui.hpp"
but for 3 beta: > include "opencv2/imgcodecs.hpp" include "opencv2/highgui/highgui.hpp"
Conclusion: I've done stupid thing in the very begginig
so what was the solution ???
@franken, look at his last reply. He mixed up 2.41 and 3.0 installations.