Building OpenCV with oneAPI
Table of Contents
Prev Tutorial: Installation in Linux
Prev Tutorial: Installation in Linux
| Original author | Alessandro de Oliveira Faria |
| Compatibility | OpenCV >= 4.11.0 |
oneAPI is Intel's open initiative (now also maintained by the UXL Foundation) that combines a specification and a set of toolkits for programming CPUs, GPUs, FPGAs and NPUs with a single code base. The core is the SYCL standard (single-source C++ for parallelism), complemented by high-performance libraries — oneTBB (parallelism), oneMKL (linear algebra), oneDNN (neural networks), oneVPL (video), etc. Thus, when you compile with oneAPI's DPC++ (icpx) compiler, the binary gains optimized execution paths that choose, at runtime, the best vector instructions or the available device, without changing the source code.
Systems based on Intel® 64 architectures below are supported both as host and target platforms.
Installing oneAPI: To quickly set up the oneAPI ecosystem on openSUSE, simply follow the official guide https://www.intel.com/content/www/us/en/developer/articles/guide/installation-guide-for-oneapi-toolkits.html, which shows you how to enable the distribution’s dedicated repository (zypper ar … oneAPI) and install the metapackages ― for example, intel-basekit (DPC++, TBB, oneDNN, IPP compilers) and, optionally, intel-hpckit or intel-renderkit if you need HPC or graphics tools. The guide also explains post-installation tweaks, such as loading the environment with source /opt/intel/oneapi/setvars.sh , ensuring that the binaries (icpx, dpcpp) and libraries are immediately available in your shell for compiling and running accelerated applications.
git clone https://github.com/opencv/opencv.gitgit status
On branch 4.xcd opencv
mkdir build
cd buildsource /opt/intel/oneapi/setvars.shcmake -DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=icpx
-DCMAKE_CXX_FLAGS="-march=native -mavx -mfma -msse -msse2" ..
cmake --build .readelf -p .comment bin/opencv_annotation
String dump of section '.comment':
[ 0] GCC: (SUSE Linux) 13.3.1 20250313 [revision 4ef1d8c84faeebffeb0cc01ee22e891b41e5c4e0]
[ 56] GCC: (SUSE Linux) 12.3.0
[ 6f] Intel(R) oneAPI DPC++/C++ Compiler 2025.1.1 (2025.1.1.20250418)
make installHave fun...