我为mac OSX(Mavericks)下载了opencv 2.4.6。解开tar文件并进行以下steps:
cd opencv-2.4.6.1/
mkdir build
cd build/
cmake -G "Unix Makefiles" ..
make -j8
但是我在构建上遇到错误
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/core/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/imgproc/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(core)
^~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
CV_PERF_TEST_MAIN(imgproc)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/highgui/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(highgui)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
1 error generated.
1 error generated.
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [modules/highgui/CMakeFiles/opencv_perf_highgui.dir/perf/perf_main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
1 error generated.
make[2]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2
[ 50%] [ 50%] [ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_perf_highgui.dir/perf/perf_precomp.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_fast.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_descriptors_regression.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_detectors_regression.cpp.o
[ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_ffmpeg.cpp.o
[ 50%] Building CXX object modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/perf/perf_main.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_main.cpp.o
make[1]: *** [modules/highgui/CMakeFiles/opencv_perf_highgui.dir/all] Error 2
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_fast.cpp.o
[ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_fourcc.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_orb.cpp.o
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/calib3d/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(calib3d)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_keypoints.cpp.o
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/features2d/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(features2d)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
1 error generated.
make[2]: *** [modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/all] Error 2
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_precomp.cpp.o
1 error generated.
make[2]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_framecount.cpp.o
[ 51%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_main.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_grfmt.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_gui.cpp.o
[ 51%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_matchers_algorithmic.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_main.cpp.o
[ 51%] [ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_positioning.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_mser.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_precomp.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_video_io.cpp.o
make[1]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d.dir/all] Error 2
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_nearestneighbors.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_video_pos.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_orb.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_precomp.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_rotation_and_scale_invariance.cpp.o
Linking CXX executable ../../bin/opencv_test_highgui
[ 52%] Built target opencv_test_highgui
Linking CXX executable ../../bin/opencv_test_features2d
[ 52%] Built target opencv_test_features2d
make: *** [all] Error 2
答案 0 :(得分:5)
我将这个编译选项用于cmake:
cmake -G "Unix Makefiles" -D CMAKE_INSTALL_PREFIX=/Users/produit/Library/Developer/opencv/ -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_legacy=NO ..
答案 1 :(得分:1)
奇怪的是,这个bug已经被报道了! http://code.opencv.org/issues/3179
已经解决了: https://github.com/Itseez/opencv/pull/1244
[...]的OpenCV-2.4.6.1 /模块/ TS /包含/ opencv2 / TS / ts_perf.hpp
以下内容:
#if defined(_MSC_VER) && (_MSC_VER <= 1400)
#define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...) \
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/
#else
#define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...) \
__VA_ARGS__;
#endif
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
CV_PERF_TEST_MAIN_INTERNALS_ARGS(__VA_ARGS__) \'
而不是:
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\
https://github.com/vkocheganov/opencv/commit/e4b201be25ff92e930b979098e94a89368677313