我正在尝试按照此博客在 Mac 上构建 OpenCV 4.1.0:https://www.learnopencv.com/install-opencv-4-on-macos/
这是准备 cmake 的命令行 - 成功了:
cmake -DOPENCV_EXTRA_MODULES_PATH=/git/opencv_contrib-4.1.0/modules -DPYTHON_DEFAULT_EXECUTABLE=python3 -DCMAKE_CXX_COMPILER=/usr/local/gcc-9.1/bin/g++-9.1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_opencv_python2=False -DBUILD_opencv_python3=True -DPYTHON3_EXECUTABLE=python3 ../
然后制作
make -j4
失败的原因如下internal compiler error
:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
完整输出如下:
$ make -j4
[ 1%] Built target zlib
[ 4%] Built target libjpeg-turbo
[ 4%] Built target libjasper
[ 8%] Built target libwebp
[ 8%] Built target quirc
[ 9%] Built target ippiw
[ 9%] Built target ittnotify
[ 9%] Built target opencv_videoio_plugins
[ 9%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp.o
[ 9%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/check_cycles.cpp.o
Scanning dependencies of target opencv_test_core_pch_dephelp
[ 10%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.o
[ 10%] Building CXX object modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.o
In file included from /git/opencv-4.1.0/3rdparty/protobuf/src/google/protobuf/arena.h:36,
from /git/opencv-4.1.0/3rdparty/protobuf/src/google/protobuf/arena.cc:31:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.o] Error 1
make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 10%] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/edge.cpp.o
In file included from /usr/local/gcc-9.1/include/c++/9.1.0/bits/uniform_int_dist.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/bits/stl_algo.h:66,
from /usr/local/gcc-9.1/include/c++/9.1.0/algorithm:62,
from /git/opencv-4.1.0/build/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp:12:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/alloc.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /usr/local/gcc-9.1/include/c++/9.1.0/bits/hashtable_policy.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/bits/hashtable.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/unordered_map:46,
from /git/opencv-4.1.0/build/3rdparty/ade/ade-0.1.1d/sources/ade/source/check_cycles.cpp:9:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/check_cycles.cpp.o] Error 1
In file included from /usr/local/gcc-9.1/include/c++/9.1.0/bits/uniform_int_dist.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/bits/stl_algo.h:66,
from /usr/local/gcc-9.1/include/c++/9.1.0/algorithm:62,
from /git/opencv-4.1.0/modules/core/include/opencv2/core/base.hpp:55,
from /git/opencv-4.1.0/modules/core/include/opencv2/core.hpp:54,
from /git/opencv-4.1.0/modules/ts/include/opencv2/ts.hpp:10,
from /git/opencv-4.1.0/modules/core/test/test_precomp.hpp:7,
from /git/opencv-4.1.0/build/modules/core/opencv_test_core_pch_dephelp.cxx:1:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/all] Error 2
In file included from /usr/local/gcc-9.1/include/c++/9.1.0/bits/hashtable_policy.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/bits/hashtable.h:35,
from /usr/local/gcc-9.1/include/c++/9.1.0/unordered_map:46,
from /git/opencv-4.1.0/build/3rdparty/ade/ade-0.1.1d/sources/ade/include/ade/graph.hpp:15,
from /git/opencv-4.1.0/build/3rdparty/ade/ade-0.1.1d/sources/ade/source/edge.cpp:12:
/usr/local/gcc-9.1/include/c++/9.1.0/limits:1668:7: internal compiler error: Illegal instruction: 4
1668 | max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
| ^~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/edge.cpp.o] Error 1
make[1]: *** [modules/CMakeFiles/ade.dir/all] Error 2
make: *** [all] Error 2
openCV
如果有任何人士曾在 Mac 上(以及使用)成功构建过此版本,opencv_contrib
我将非常感谢他们的提供建议。