# Build with Mingw (MSYS2 UCRT64) on Windows fails

**URL:** <https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460>\
**Category:** C++\
**Tags:** windows, orbbec, videoio, build\
**Created:** [December 31, 2022, 11:05am UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460 "2022-12-31T11:05:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [December 31, 2022, 11:05am UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/1 "2022-12-31T11:05:35Z")

</div>

Hi everybody.

This is my environment for building OPENCV:  
OS: Windows 11  
Windows SDK: Windows 10.0.22621 AMD64  
Generator: Ninja  
Compiler: UCRT64 GCC (MSYS2)

I’m building with DSHOW OFF but the compilation failed with this errors (used `cmake --build buildgcc --target install`):

```auto
FAILED: modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap_obsensor/obsensor_uvc_stream_channel.cpp.obj
[...]
FAILED: modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap_obsensor/obsensor_stream_channel_msmf.cpp.obj

```

Follow:

- CMake configuration command used
- CMake configuration review
- Complete error

Please, not that all the commands have been executed in MSYS UCRT64 shell:

```auto
cmake -B"C:/workspace/libs/opencv/buildgcc" -H"C:/workspace/libs/opencv" -G"Ninja" -DCMAKE_BUILD_TYPE=Release \
-DOPENCV_EXTRA_MODULES_PATH="C:/workspace/libs/opencv/opencv_contrib/modules" -DCMAKE_CXX_STANDARD=14 -DCMAKE_INSTALL_PREFIX="C:/workspace/libs/opencv/buildgcc/install" -DINSTALL_TESTS=ON -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DBUILD_EXAMPLES=OFF \
-DBUILD_opencv_world=ON \
-DWITH_OPENGL=ON \
-DWITH_TBB=OFF \
-DWITH_IPP=OFF \
-DMKL_WITH_TBB=OFF \
-DWITH_EIGEN=ON -DEIGEN_INCLUDE_PATH="C:/workspace/libs/eigen" \
-DWITH_MFX=OFF \
-DMKL_USE_MULTITHREAD=OFF \
-DWITH_MKL=OFF \
-DWITH_MSMF=OFF \
-DWITH_OPENMP=ON \
-DCPU_BASELINE=AVX2,SSE4.2 \
-DWITH_GSTREAMER=ON \
-DWITH_DSHOW=OFF

```

CMake Configuration overview:

```auto
-- ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
-- Detected processor: AMD64
-- Found PythonInterp: C:/local/msys64/ucrt64/bin/python.exe (found suitable version "3.10.9", minimum required is "2.7")
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX - Success
-- libjpeg-turbo: VERSION = 2.1.3, BUILD = opencv-4.7.0-dev-libjpeg-turbo
-- CMAKE_ASM_NASM_COMPILER = C:/local/msys64/ucrt64/bin/nasm.exe
-- SIMD extensions: x86_64 (WITH_SIMD = 1)
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.7.0-dev-openjp2-2.4.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find BLAS (missing: BLAS_LIBRARIES)
-- Could NOT find LAPACK (missing: LAPACK_LIBRARIES)
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 AWT JVM)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Checking for module 'gstreamer-app-1.0'
-- Package 'gstreamer-app-1.0', required by 'virtual:world', not found
-- Checking for module 'gstreamer-riff-1.0'
-- Package 'gstreamer-riff-1.0', required by 'virtual:world', not found
-- Checking for module 'gstreamer-pbutils-1.0'
-- Package 'gstreamer-pbutils-1.0', required by 'virtual:world', not found
-- Checking for module 'gstreamer-video-1.0'
-- Package 'gstreamer-video-1.0', required by 'virtual:world', not found
-- Checking for module 'gstreamer-audio-1.0'
-- Package 'gstreamer-audio-1.0', required by 'virtual:world', not found
-- Checking for module 'libdc1394-2'
-- Package 'libdc1394-2', required by 'virtual:world', not found
-- Checking for module 'freetype2'
-- Package 'freetype2', required by 'virtual:world', not found
-- Checking for module 'harfbuzz'
-- Package 'harfbuzz', required by 'virtual:world', not found
-- freetype2: NO
-- harfbuzz: NO
-- Julia not found. Not compiling Julia Bindings.
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
-- Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
-- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
-- Checking for module 'tesseract'
-- Package 'tesseract', required by 'virtual:world', not found
-- Tesseract: NO
-- Processing WORLD modules...
-- module opencv_core...
-- Consider adding OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int/int64_t according to your build configuration
-- module opencv_flann...
-- module opencv_imgproc...
-- module opencv_intensity_transform...
-- module opencv_ml...
-- module opencv_phase_unwrapping...
-- module opencv_photo...
-- module opencv_plot...
-- module opencv_quality...
-- module opencv_reg...
-- module opencv_surface_matching...
-- module opencv_xphoto...
-- module opencv_alphamat...
-- module opencv_dnn...
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/workspace/libs/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- module opencv_dnn_superres...
-- module opencv_features2d...
-- module opencv_fuzzy...
-- module opencv_hfs...
-- module opencv_imgcodecs...
-- imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
-- module opencv_line_descriptor...
-- module opencv_saliency...
-- module opencv_text...
-- module opencv_videoio...
-- module opencv_barcode...
-- module opencv_calib3d...
-- module opencv_datasets...
-- module opencv_highgui...
-- highgui: using builtin backend: WIN32UI
-- module opencv_mcc...
-- module opencv_objdetect...
-- module opencv_rapid...
-- module opencv_rgbd...
-- module opencv_shape...
-- module opencv_structured_light...
-- module opencv_video...
-- module opencv_videostab...
-- module opencv_wechat_qrcode...
-- module opencv_xfeatures2d...
-- module opencv_ximgproc...
-- module opencv_xobjdetect...
-- module opencv_aruco...
-- module opencv_bgsegm...
-- module opencv_bioinspired...
-- module opencv_ccalib...
-- module opencv_dnn_objdetect...
-- module opencv_dpm...
-- module opencv_face...
-- module opencv_gapi...
-- module opencv_optflow...
-- module opencv_stitching...
-- module opencv_superres...
-- module opencv_tracking...
-- module opencv_stereo...
-- Processing WORLD modules... DONE
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/world/layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/world/layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/world/int8layers/layers_common.lasx.cpp
-- Found 'misc' Python modules from C:/workspace/libs/opencv/modules/python/package/extra_modules
-- Found 'mat_wrapper;utils' Python modules from C:/workspace/libs/opencv/modules/core/misc/python/package
-- Found 'gapi' Python modules from C:/workspace/libs/opencv/modules/gapi/misc/python/package
--
-- General configuration for OpenCV 4.7.0-dev =====================================
-- Version control: 4.7.0-1-g9208dcb07c
--
-- Extra modules:
-- Location (extra): C:/workspace/libs/opencv/opencv_contrib/modules
-- Version control (extra): 4.7.0
--
-- Platform:
-- Timestamp: 2022-12-31T09:55:49Z
-- Host: Windows 10.0.22621 AMD64
-- CMake: 3.25.1
-- CMake generator: Ninja
-- CMake build tool: C:/local/msys64/ucrt64/bin/ninja.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- requested: AVX2 SSE4.2
-- Dispatched code generation: AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- AVX512_SKX (8 files): + AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 14
-- C++ Compiler: C:/local/msys64/ucrt64/bin/c++.exe (ver 12.2.0)
-- C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: C:/local/msys64/ucrt64/bin/cc.exe
-- C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -fvisibility=hidden -fopenmp -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -fvisibility=hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--gc-sections
-- Linker flags (Debug): -Wl,--gc-sections
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: pthread
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: -
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 python3 sfm viz
-- Applications: tests perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Windows RT support: NO
--
-- GUI:
-- Win32 UI: YES
-- OpenGL support: YES (opengl32 glu32)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.2.13)
-- JPEG: build-libjpeg-turbo (ver 2.1.3-62)
-- SIMD Support Request: YES
-- SIMD Support: YES
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.2.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES (prebuilt binaries)
-- avcodec: YES (58.134.100)
-- avformat: YES (58.76.100)
-- avutil: YES (56.70.100)
-- swscale: YES (5.9.100)
-- avresample: YES (4.0.0)
-- GStreamer: NO
-- DirectShow: YES
--
-- Parallel framework: OpenMP
--
-- Trace: YES (built-in)
--
-- Other third-party libraries:
-- Lapack: NO
-- Eigen: YES (ver 3.4.90)
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
--
-- OpenCL: YES (NVD3D11)
-- Include path: C:/workspace/libs/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python (for build): C:/local/msys64/ucrt64/bin/python3.exe
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: C:/workspace/libs/opencv/buildgcc/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/workspace/libs/opencv/buildgcc

```

Complete error log: available [here](https://pastebin.com/A1mtLFwp) (too long to be written here)

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 31, 2022, 11:25am UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/2 "2022-12-31T11:25:23Z")

</div>

> [@buzz](#):
>
> I’m building with DSHOW OFF

why so ?  
(it’s the only webcam backend you can use with mingw !)

> [@buzz](#):
>
> ```auto
> FAILED: modules/world/CMakeFiles/opencv_world.dir/__/videoio/src/cap_obsensor/obsensor_uvc_stream_channel.cpp.obj
> 
> ```

mingw does not come with support code for MSMF, so you cannot build that backend (use `WITH_MSMF=OFF` as well as `WITH_OBSSENSOR=OFF` cmake option to disable it)

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [December 31, 2022, 11:47am UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/3 "2022-12-31T11:47:22Z")

</div>

Thank you for the precious advice, I’m gonna try that soon. Just for info (sorry for being quite new to opencv), what does `obssensor` module is and why isn’t it compatible with GCC? Thank you again.  
BTW: MSMF is already set to OFF. I thought DSHOW was a windows backend not compatible with mingw GCC.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 31, 2022, 12:18pm UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/4 "2022-12-31T12:18:46Z")

</div>

> [@buzz](#):
>
> what does `obssensor` module is

it’s one possible backend for VideoCapture  
(like DSHOW, FFMPEG, MSMF, …)  
you can use [orbbec](https://orbbec3d.com/) hardware with it.

> [@buzz](#):
>
> and why isn’t it compatible with GCC? Thank you again.  
> BTW:

again, it relies on the missing support code for [MSMF](https://learn.microsoft.com/en-us/windows/win32/medfound/microsoft-media-foundation-sdk) (not a problem with gcc per se)

> [@buzz](#):
>
> I thought DSHOW was a windows backend not compatible with mingw GCC.

mingw actually should support this (at least mingw64 8.1 does)

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [December 31, 2022, 12:33pm UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/5 "2022-12-31T12:33:46Z")

</div>

You’re very right and you made my day. Thank you very much!  
Just an observation: the actual key is `-DWITH_OBSENSOR=OFF` and not `-DWITH_OBSSENSOR=OFF` (check the double S). But, this is just minor stuff. Again, thank you a lot

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [December 31, 2022, 12:47pm UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/6 "2022-12-31T12:47:04Z")

</div>

hehe, [right](https://github.com/opencv/opencv/blob/9208dcb07c015e1fda44e40bb07b43c700b4bf46/CMakeLists.txt#L468)

if it works, kindly [add an explanation to your gh issue](https://github.com/opencv/opencv/issues/23070), & close it , thank you !

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [December 31, 2022, 1:07pm UTC](https://forum.opencv.org/t/build-with-mingw-msys2-ucrt64-on-windows-fails/11460/7 "2022-12-31T13:07:30Z")

</div>

Already done. Commented and closed 🙂
