Ask Your Question
0

OpenCV 2.4.5 on OSX 10.6.8 with c++ 11 support - make errors

asked 2013-04-30 12:00:42 -0600

Andeep Toor gravatar image

updated 2013-04-30 12:14:43 -0600

I am building opencv 2.4.5 from source, with options to support clang, c++ 11, and libc++. When running make, I get the error listed in the section below.

I have also checked out the master branch from https://github.com/Itseez/opencv/archive/master.zip and verified that this same problem occurs (The stack trace below is from opencv-master, checked out today). Does anyone one have any idea on how to fix this issue?

My environment is the following:

OS:

Mac OSX 10.6.8

Clang:

clang version 3.3 (trunk 180676) Target: x86_64-apple-darwin10.8.0 Thread model: posix

Cmake command:

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_CUDA=OFF ../

This is the error that I get:

Scanning dependencies of target opencv_legacy [ 59%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/3dtracker.cpp.o [ 59%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/auxutils.cpp.o [ 59%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/bgfg_acmmm2003.cpp.o [ 59%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/bgfg_codebook.cpp.o [ 59%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/bgfg_common.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/bgfg_estimation.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/bgfg_gaussmix.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrack.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackanalysis.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackanalysishist.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackanalysisior.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackanalysistrackdist.cpp.o [ 60%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackgen1.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackgenyml.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackingauto.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackingcc.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackingccwithcr.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackinglist.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackingmsfg.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackingmsfgs.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackpostprockalman.cpp.o [ 61%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackpostproclinear.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/blobtrackpostproclist.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/calcimagehomography.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/calibfilter.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/calonder.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/camshift.cpp.o [ 62%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src ... (more)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-06 22:20:22 -0600

natrium1970 gravatar image

This is an error in OpenCV. The macros CV_IMAX3 and CV_IMIN3 both refer to a temporary variable temp3. Later, these macros are used in code like the following:

if( ( CV_IMAX3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] ) - CV_IMIN3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] ) ) >= ICV_BIRCH_DIFF_LUM ) . . .

which has the form

if ( (expr1 - expr2 ) >= ICV_BIRCH_DIFF_LUM) . . .

The C++ language makes no guarantee about the order in which expr1 and expr2 will be evaluated. In fact, the computations could even be interwoven. Because expr1 and expr2 both alter (i.e. have side effects on) and use temp3, the result is not well-defined.

In my code, I replaced the #define directives in dpstereo.cpp with

define CV_IMIN3(a, b, c) std::min(std::min(a, b), c)

define CV_IMAX3(a, b, c) std::max(std::max(a, b), c)

For reference, this type of issue is covered the C++11 standard in section 1.9, starting in paragraph 13. Search for "sequenced before." This concept used to be described as "sequence points" in previous C++ standards. The effect of "sequence points" is still in C++11, but it was decided to drop the term and explain the behavior in-text.

This issue might not show up in other compilers because Clang tends to be more thorough in its error checking.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-04-30 12:00:42 -0600

Seen: 504 times

Last updated: Jul 06 '13