2013-10-25 81 views
4

我爲mac OSX(Mavericks)下載了opencv 2.4.6。 Untared tar文件,並提出以下steps在Mac上建立opencv 2.4.6 - 小牛

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

與'make',而不是'讓-j8'嘗試。我以前見過這會導致OpenCV出現問題。我知道,這很奇怪。 – karlphillip

回答

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 .. 
+0

我有同樣的問題,像OP,這確實做了詭計,謝謝 – JonEasy

+0

謝謝皮埃爾的這個提示。 – tuscland

1

很奇怪,該錯誤已經被報道! http://code.opencv.org/issues/3179

,並已得到了解決: https://github.com/Itseez/opencv/pull/1244


還有 - 一個快速的解決方案:

  • 開拓

[...]的OpenCV -2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp

  • 圍繞線480編輯:

與以下內容:

#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

  • 爲我工作:-)