如何修复OSX上的OpenCV 4编译错误

时间:2018-11-24 14:59:48

标签: c++ opencv cmake compiler-errors

我已经从opencv存储库中提取了最新的更改,并且正在尝试从源代码进行编译。上一次我尝试使用OpenCV 3.2.2进行此操作,但是这次是在4.0上,我遇到了很多这样的错误:

[ 57%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/mathfuncs_core.avx2.cpp.o
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:49:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/utility.hpp:56:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core.hpp:52:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/cvdef.h:772:39: error: use of undeclared identifier '_mm_cvtps_ph'; did you mean '_mm_cvtss_sd'?
        w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0));
                                      ^~~~~~~~~~~~
                                      _mm_cvtss_sd
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include/emmintrin.h:420:1: note: '_mm_cvtss_sd' declared here
_mm_cvtss_sd(__m128d __a, __m128 __b)
^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:49:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/utility.hpp:56:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core.hpp:52:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/cvdef.h:772:55: error: cannot initialize a parameter of type '__m128' (vector of 4 'float' values) with an rvalue of type 'int'
        w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0));
                                                      ^
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include/emmintrin.h:420:34: note: passing argument to parameter '__b' here
_mm_cvtss_sd(__m128d __a, __m128 __b)
                                 ^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:49:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/utility.hpp:56:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core.hpp:52:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/cvdef.h:803:26: error: use of undeclared identifier '_mm_cvtph_ps'; did you mean '_mm_cvtpd_ps'?
        _mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w)));
                         ^~~~~~~~~~~~
                         _mm_cvtpd_ps
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include/emmintrin.h:376:1: note: '_mm_cvtpd_ps' declared here
_mm_cvtpd_ps(__m128d __a)
^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:85:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:179:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin_avx.hpp:2551:24: error: use of undeclared identifier '_mm256_cvtph_ps'; did you mean '_mm256_cvtpd_ps'?
    return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr)));
                       ^~~~~~~~~~~~~~~
                       _mm256_cvtpd_ps
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include/avxintrin.h:539:1: note: '_mm256_cvtpd_ps' declared here
_mm256_cvtpd_ps(__m256d __a)
^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:85:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:179:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin_avx.hpp:2551:40: error: cannot initialize a parameter of type '__m256d' (vector of 4 'double' values) with an rvalue of type '__m128i' (vector of 2 'long long' values)
    return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr)));
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include/avxintrin.h:539:25: note: passing argument to parameter '__a' here
_mm256_cvtpd_ps(__m256d __a)
                        ^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/core/mathfuncs_core.avx2.cpp:2:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/src/precomp.hpp:85:
In file included from /Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:179:
/Users/George/Downloads/Grouped/cv/opencv/modules/core/include/opencv2/core/hal/intrin_avx.hpp:2556:18: error: use of undeclared identifier '_mm256_cvtps_ph'
    __m128i ah = _mm256_cvtps_ph(a.val, 0);
                 ^
6 errors generated.
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/mathfuncs_core.avx2.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

我在OSX 10.11.6上使用Xcode 7.0,这是cmake的输出:

-- Looking for ccache - not found
-- FP16 is not supported by C++ compiler
-- AVX_512F is not supported by C++ compiler
-- AVX512_SKX is not supported by C++ compiler
-- Dispatch optimization FP16 is not available, skipped
-- Dispatch optimization AVX512_SKX is not available, skipped
-- libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.0-dev-libjpeg-turbo
-- Checking for module 'gstreamer-base-1.0'
--   No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
--   No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
--   No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
--   No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
--   No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
--   No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
--   No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
--   No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
--   No package 'gstreamer-riff-0.10' found
-- Checking for module 'gstreamer-pbutils-0.10'
--   No package 'gstreamer-pbutils-0.10' found
-- Checking for module 'libdc1394-2'
--   No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
--   No package 'libdc1394' found
-- found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
-- at: /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/3rdparty/ippicv/ippicv_mac/icv
-- Cannot find Intel IPP Integration Wrappers, optimizations will be limited. Use IPPIWROOT to set custom location
-- Found apache ant: /usr/local/bin/ant (1.9.7)
-- Found VTK 7.1.1 (/usr/local/Cellar/vtk/7.1.1_1/lib/cmake/vtk-7.1/UseVTK.cmake)
-- OpenCV Python: during development append to PYTHONPATH: /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/python_loader
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /Users/George/Downloads/Grouped/cv/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out ocl4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- 
-- General configuration for OpenCV 4.0.0-dev =====================================
--   Version control:               4.0.0-29-g02cc1cd
-- 
--   Platform:
--     Timestamp:                   2018-11-23T11:45:27Z
--     Host:                        Darwin 15.6.0 x86_64
--     CMake:                       3.12.4
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3 SSSE3
--       requested:                 DETECT
--     Dispatched code generation:  SSE4_1 SSE4_2 AVX AVX2
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (5 files):          + SSE4_1
--       SSE4_2 (1 files):          + SSE4_1 POPCNT SSE4_2
--       AVX (4 files):             + SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (11 files):           + SSE4_1 POPCNT SSE4_2 FMA3 AVX AVX2
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  (ver 7.0.0.7000072)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -g1
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /Applications/IDEsAndEditors/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -g1
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      
--     Linker flags (Debug):        
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java java_bindings_generator ml objdetect photo python_bindings_generator stitching ts video videoio
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 js python2 python3
--     Applications:                apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     Cocoa:                       YES
--     VTK support:                 YES (ver 7.1.1)
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        build-libjpeg-turbo (ver 1.5.3-62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.35)
--     TIFF:                        build (ver 42 - 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.89.100)
--       avformat:                  YES (ver 57.71.100)
--       avutil:                    YES (ver 55.58.100)
--       swscale:                   YES (ver 4.6.100)
--       avresample:                YES (ver 3.5.0)
--     GStreamer:                   NO
--     AVFoundation:                YES
-- 
--   Parallel framework:            GCD
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2019.0.0 Gold [2019.0.0]
--            at:                   /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/3rdparty/ippicv/ippicv_mac/icv
--     Intel IPP IW:                NO
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                NO
--     Link libraries:              -framework OpenCL
-- 
--   Python (for build):            /usr/local/bin/python2.7
-- 
--   Java:                          
--     ant:                         /usr/local/bin/ant (ver 1.9.7)
--     JNI:                         /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/include
--     Java wrappers:               YES
--     Java tests:                  NO
-- 
--   Install to:                    /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/install
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava

我认为这与Accelerate / BLAS / LAPACK有关,并且我将WITH_LAPACK设置为OFF,但是错误仍然存​​在。

我应该注意的任何线索吗?

更新,我已经重新阅读了这些错误,它们与AVX2 CPU指令有关。 我记得曾经在3.2.2上使用过AVX2优化,但是我暂时将其禁用,可以编译。

在构建emscripten js模块时遇到一些错误:

[ 97%] Building CXX object modules/js/CMakeFiles/opencv_js.dir/bindings.cpp.o
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/js/bindings.cpp:71:
In file included from /Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:10:
In file included from /Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/val.h:4:
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/wire.h:383:37: warning: declaration shadows a field of 'memory_view<ElementType>' [-Wshadow]
        explicit memory_view(size_t size, const ElementType* data)
                                    ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/wire.h:388:22: note: previous declaration is here
        const size_t size; // in elements, not bytes
                     ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/wire.h:383:62: warning: declaration shadows a field of 'memory_view<ElementType>' [-Wshadow]
        explicit memory_view(size_t size, const ElementType* data)
                                                             ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/wire.h:389:27: note: previous declaration is here
        const void* const data;
                          ^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/js/bindings.cpp:71:
In file included from /Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:10:
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/val.h:173:9: error: static_assert failed "GenericWireType must be 8 bytes"
        static_assert(sizeof(GenericWireType) == 8, "GenericWireType must be 8 bytes");
        ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/val.h:439:39: warning: declaration shadows a field of 'emscripten::val' [-Wshadow]
        explicit val(internal::EM_VAL handle)
                                      ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/val.h:464:26: note: previous declaration is here
        internal::EM_VAL handle;
                         ^
In file included from /Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/js/bindings.cpp:71:
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:841:34: warning: unused parameter 'v' [-Wunused-parameter]
        static void* share(void* v) {
                                 ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:887:38: warning: declaration shadows a field of 'emscripten::smart_ptr_trait<shared_ptr<type-parameter-0-0> >::val_deleter' [-Wshadow]
            explicit val_deleter(val v)
                                     ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:896:17: note: previous declaration is here
            val v;
                ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:924:32: warning: declaration shadows a field of 'wrapper<T>' [-Wshadow]
        explicit wrapper(val&& wrapped, Args&&... args)
                               ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:941:13: note: previous declaration is here
        val wrapped;
            ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:1010:20: error: cannot cast 'cv::Algorithm *' to 'cv::Feature2D *' via virtual base 'cv::Algorithm'
            return static_cast<To*>(ptr);
                   ^~~~~~~~~~~~~~~~~~~~~
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:1005:21: note: in instantiation of function template specialization 'emscripten::base<cv::Algorithm>::convertPointer<cv::Algorithm, cv::Feature2D>' requested here
            return &convertPointer<BaseClass, ClassType>;
                    ^
/Users/George/Downloads/Libraries/emsdk_portable/emscripten/1.35.0/system/include/emscripten/bind.h:1070:53: note: in instantiation of function template specialization 'emscripten::base<cv::Algorithm>::getDowncaster<cv::Feature2D>' requested here
            auto downcast = BaseSpecifier::template getDowncaster<ClassType>();
                                                    ^
/Users/George/Downloads/Grouped/cv/opencv/buildDNNJava/modules/js/bindings.cpp:3470:5: note: in instantiation of member function 'emscripten::class_<cv::Feature2D, emscripten::base<cv::Algorithm> >::class_' requested here
    emscripten::class_<cv::Feature2D ,base<Algorithm>>("Feature2D")
    ^
6 warnings and 2 errors generated.

因此,我很高兴听到更多有关如何克服这些问题的信息,并可能启用AVX指令。

0 个答案:

没有答案