Building OpenCV with Intel oneApi C++ Compiler CMake and Visual Studio

Hello,

in my project I’m using MS Visual Studio 2022 and CMake 3.23.1.

The toolchain is building some 3rd parties like OpenCV form source using CMake’s ExternalProject infrastructure.

Using the tools mentioned above everything works as expected. Now I want to try to switch the compiler to the Intel C++ compiler as part of the Intel oneAPI. The IDE should be Visual Studio.

I configure the project as follows:

The configuration of the project seems to be fine. The Intel C++ compiler is detected but while running the CMake configuration I noticed that all tests for SSE2, SSE3, … AVX are failing.

SSE3 is not supported by C++ compiler

SSSE3 is not supported by C++ compiler

SSE4_1 is not supported by C++ compiler

POPCNT is not supported by C++ compiler

SSE4_2 is not supported by C++ compiler

FP16 is not supported by C++ compiler

AVX is not supported by C++ compiler

Optimization SSE3 is not available, skipped

Dispatch optimization SSE4_1 is not available, skipped

Dispatch optimization SSE4_2 is not available, skipped

Dispatch optimization AVX is not available, skipped

Dispatch optimization FP16 is not available, skipped

The configured Visual Studio Solution also looks fine.

Building OpenCV then ends up with lots of errors regarding SSE and AVX.

17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,8): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1361,24): error : use of undeclared identifier '_mm_fmadd_ps'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,41): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,59): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,8): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1370,24): error : use of undeclared identifier '_mm_fmadd_pd'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,40): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,57): error : unknown type name '__m256'
17>TRACKEDEXEC : fatal error : too many errors emitted, stopping now [-ferror-limit=]
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1361,24): error : use of undeclared identifier '_mm_fmadd_ps'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(22,8): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_sse.hpp(1370,24): error : use of undeclared identifier '_mm_fmadd_pd'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(23,34): error : use of undeclared identifier '_mm256_castsi128_si256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(25,8): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(26,31): error : use of undeclared identifier '_mm256_castps128_ps256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(28,8): error : unknown type name '__m256d'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(29,31): error : use of undeclared identifier '_mm256_castpd128_pd256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(31,35): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(34,8): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(34,43): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(37,8): error : unknown type name '__m256d'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(37,43): error : unknown type name '__m256d'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,8): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(22,8): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,41): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(41,59): error : unknown type name '__m256i'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(23,34): error : use of undeclared identifier '_mm256_castsi128_si256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,8): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(25,8): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,40): error : unknown type name '__m256'
17>...\OpenCV\modules\core\include\opencv2/core/hal/intrin_avx.hpp(45,57): error : unknown type name '__m256'
17>TRACKEDEXEC : fatal error : too many errors emitted, stopping now [-ferror-limit=]

Does anyone have experience with building OpenCV with the Intel C++ Compiler? Are there some special flags missing?

Thanks and best regards,
Dirk