OpenBLAS support using OpenCV built with vcpkg

Hi everyone, I need your support to better understand the usage of OpenBLAS in OpenCV.

Project Description

I have a project in which I use OpenCV as a dependency.
The library is downloaded and compiled using vcpkg, CMake and MSVC.

I would like to add OpenBLAS as a dependency of my project.
I read online that OpenCV has support for the usage of a BLAS/LAPACK library, but I cannot find any detailed information in the documentation.

VCPKG Integration

In the vcpkg.json of my project I enabled the OpenCV’s lapack feature, which I suppose enables the LAPACK/BLAS interface.
I also added OpenBLAS as a dependency.

After performing this steps, I notice a new print in the vcpkg log during configuration

-- Running vcpkg install - done
-- Using VCPKG FindLAPACK from package 'lapack-reference'
-- A library with LAPACK API found.

From this, I suppose that OpenCV has found the OpenBLAS dependency.
Printing the build information using cv::getBuildInformation() I obtain the following

General configuration for OpenCV 4.6.0 =====================================
  Version control:               unknown

    Timestamp:                   2024-01-10T14:28:17Z
    Host:                        Windows 10.0.22621 AMD64
    CMake:                       3.27.4
    CMake generator:             Ninja
    CMake build tool:            C:/lib/vcpkg/downloads/tools/ninja/1.10.2-windows/ninja.exe
    MSVC:                        1916
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (14 files):         + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

    Built as dynamic libs?:      NO
    C++ standard:                11
    C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe  (ver 19.16.27051.0)
    C++ flags (Release):         /nologo /DWIN32 /D_WINDOWS /W4 /utf-8 /GR /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589  /MT /O2 /Oi /Gy /DNDEBUG /Z7
    C++ flags (Debug):           /nologo /DWIN32 /D_WINDOWS /W4 /utf-8 /GR /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589  /D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe
    C flags (Release):           /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS       /MT /O2 /Oi /Gy /DNDEBUG /Z7
    C flags (Debug):             /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise /FS     /D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /NODEFAULTLIB:atlthunk.lib /nologo /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF    /debug /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
    Linker flags (Debug):        /machine:x64  /NODEFAULTLIB:atlthunk.lib /nologo    /debug /INCREMENTAL  /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          protobuf::libprotobuf comctl32 gdi32 ole32 setupapi ws2_32 quirc::quirc
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo stitching video videoio world
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 gapi java python2 python2 python3 ts
    Applications:                -
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

    Win32 UI:                    YES

  Media I/O:
    ZLib:                        optimized C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/lib/zlib.lib debug C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/debug/lib/zlibd.lib (ver 1.2.13)
    JPEG:                        optimized C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/lib/jpeg.lib debug C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/debug/lib/jpeg.lib (ver 62)
    WEBP:                        (ver 1.2.4)
    PNG:                         optimized C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/lib/libpng16.lib debug C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/debug/lib/libpng16d.lib (ver 1.6.39)
    TIFF:                        optimized C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/lib/tiff.lib debug C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/debug/lib/tiffd.lib (ver 42 / 4.4.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            Concurrency

  Trace:                         YES (built-in)

  Other third-party libraries:
    Lapack:                      NO
    Custom HAL:                  NO
    Protobuf:                    optimized C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/lib/libprotobuf.lib debug C:/Users/***/Documents/projects/***/build/release/vcpkg_installed/x64-windows-static-v141/debug/lib/libprotobufd.lib   version (

  OpenCL:                        YES (NVD3D11)
    Include path:                C:/lib/vcpkg/buildtrees/opencv4/src/4.6.0-9a95a1b699.clean/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            NO

  Install to:                    C:/lib/vcpkg/packages/opencv4_x64-windows-static-v141


  • From the Other third-party libraries: I can see that a path for Lapack is not provided. Is this correct?
  • How can I be sure that OpenCV has detected the OpenBLAS library?
  • Is there any point in the documentation where the integration with a BLAS library is documented? How can I know which functions are affected by the usage of a BLAS library?

Thanks in advance for your help!

How I built OpenBLAS with OpenCV. I will not describe how to build all OpenCV, only its OpenBLAS part.

  1. My environment: MS Win 10, MSVC 2022, CMake 3.29.0, OpenCV 4.9.0, NASM
  2. Download the BLAS Binary Package:
    Releases · OpenMathLib/OpenBLAS · GitHub
  3. Extract it:
  • OpenBLAS_INCLUDE_DIRS C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/include
  • OpenBLAS_LIB C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/lib/libopenblas.lib
  • OpenBLAS bin: C:\Users\kvy\Downloads\Built_opencv4.9\OpenBLAS-0.3.26-x86\bin\libopenblas.dll
  1. Run CMake GUI and connect OpenCV package there, for example,
    Install OpenCV 3 on Windows | LearnOpenCV #
  2. In CMake GUI check on the box “Advanced” add the following the parameters:
- OpenBLAS_INCLUDE_DIRS - C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/include
- OpenBLAS_LIB - C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/lib/libopenblas.lib
  1. Press “Configure”. I got the following there:
LAPACK(OpenBLAS): LAPACK_LIBRARIES: C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/lib/libopenblas.lib
LAPACK(OpenBLAS): Support is enabled.
   Lapack:                      YES (C:/Users/kvy/Downloads/OpenBLAS-0.3.26-x86/lib/libopenblas.lib)
  1. Finish to build OpenCV,
  2. Add libopenblas.dll from BLAS Binary Package to my MSVC project