Build from source succeed but test core failed on windows (C++, CMake)

if I hit the ignore button instead of retry on the assertion dialog I get the following exist code:

 1/39 Test  #1: opencv_test_core .................Exit code 0xc0000409

This was not the case when I did for example the Release build as it was just saying test failed without anything else.

Original Post:
I am trying to build OpenCV from source on windows 11. Here is how I do it:

> git clone --depth=1 && cd opencv
cmake -GNinja -B build -DCMAKE_BUILD_TYPE=Debug .
cmake --build build
cmake --build build --target test

and this gets me the following output for a while(45 minutes or so):

W:\opencv>cmake --build build\ --target test
[0/1] Running tests...Test project W:/opencv/build
      Start  1: opencv_test_core

then I get the following image:

and on the command line I get:

 1/39 Test  #1: opencv_test_core .................***Failed

any ideas why is that the case?
my cl.exe version is Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
cmake version 3.28.1
ninja --version

Please let me know if there are any ways I can provide more information and if there is any wrong with my build environment (I followed basic instruction here: OpenCV: OpenCV installation overview)

Where do you find target test?

cmake --build --target install

I am not sure I understand what you mean by: “where did you find target test”. I just run the tests (since such a large project always has test suite, I just run the target tests as a common practice when building any large software) was I not supposed to run tests?
I don’t want to globally install opencv on my system, I would like to include it locally in my project.

I updated the question with a new exist error code that might be useful.

I don’t know what is target test for opencv.
Now you already build opencv with cmake --build build
What do you want to do with test?

If you want to run test follow tutorial :

Build tests, samples and applications

There are two kinds of tests: accuracy (opencv_test_*) and performance (opencv_perf_*). Tests and applications are enabled by default. Examples are not being built by default and should be enabled explicitly.

Corresponding cmake options:

cmake \




-DBUILD_opencv_apps=ON \


Okay, so if my understanding is correct, if the tests failed, it means my building for libs/exe/includes are corrupted one way or another. So, the reason I run the tests is that I want to ensure if I encounter any seg-fault or the like, or any weird output, it would be because I had a logic bug in my code and not because the building of the library gone wrong.

Is this concept wrong here?

test failed on windows only

linux :

[----------] 1 test from Core_reduceArgMinMax/ElemWiseTest
[ RUN      ] Core_reduceArgMinMax/ElemWiseTest.accuracy/0, where GetParam() = 16-byte object <A0-E6 B9-8B 10-56 00-00 10-AC BF-8B 10-56 00-00>
[       OK ] Core_reduceArgMinMax/ElemWiseTest.accuracy/0 (207 ms)
[----------] 1 test from Core_reduceArgMinMax/ElemWiseTest (211 ms total)


[----------] 1 test from Core_reduceArgMinMax/ElemWiseTest
[ RUN      ] Core_reduceArgMinMax/ElemWiseTest.accuracy/0, where GetParam() = 16-byte object <B0-4C 64-CB 7F-02 00-00 40-D1 05-CC 7F-02 00-00>

statck trace

opencv_test_cored.exe!std::_Debug_lt_pred<std::less_equal<unsigned __int64> &,unsigned __int64 &,unsigned __int64 &,0>(std::less_equal<unsigned __int64> & _Pred, unsigned __int64 & _Left, unsigned __int64 & _Right) Line 1141
	at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xutility(1141)
opencv_test_cored.exe!std::_Min_element_unchecked<cv::MatIterator_<unsigned __int64>,std::less_equal<unsigned __int64>>(cv::MatIterator_<unsigned __int64> _First, cv::MatIterator_<unsigned __int64> _Last, std::less_equal<unsigned __int64> _Pred) Line 6539
	at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xutility(6539)
opencv_test_cored.exe!std::min_element<cv::MatIterator_<unsigned __int64>,std::less_equal<unsigned __int64>>(cv::MatIterator_<unsigned __int64> _First, cv::MatIterator_<unsigned __int64> _Last, std::less_equal<unsigned __int64> _Pred) Line 6551
	at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xutility(6551)
opencv_test_cored.exe!cvtest::reduceMinMaxImpl<std::less_equal<unsigned __int64>,unsigned __int64>::operator()(const cv::Mat & src, cv::Mat & dst, const int axis) Line 34
	at C:\lib\opencv\modules\core\test\ref_reduce_arg.impl.hpp(34)
opencv_test_cored.exe!cv::detail::depthDispatch<cvtest::MinMaxReducer<std::less_equal>::Impl,cv::Mat const &,cv::Mat &,int &>(const int depth, const cv::Mat & <args_0>, cv::Mat & <args_1>, int & <args_2>) Line 44
	at C:\lib\opencv\modules\core\include\opencv2\core\detail\dispatch_helper.impl.hpp(44)
opencv_test_cored.exe!cvtest::MinMaxReducer<std::less_equal>::reduce(const cv::Mat & src, cv::Mat & dst, int axis) Line 72
	at C:\lib\opencv\modules\core\test\ref_reduce_arg.impl.hpp(72)
opencv_test_cored.exe!opencv_test::`anonymous namespace'::reduceArgMinMaxOp::refop(const std::vector<cv::Mat,std::allocator<cv::Mat>> & src, cv::Mat & dst, const cv::Mat & __formal) Line 1590
	at C:\lib\opencv\modules\core\test\test_arithm.cpp(1590)
opencv_test_cored.exe!opencv_test::`anonymous namespace'::ElemWiseTest_accuracy_Test::Body() Line 1648
	at C:\lib\opencv\modules\core\test\test_arithm.cpp(1648)
opencv_test_cored.exe!opencv_test::`anonymous namespace'::ElemWiseTest_accuracy_Test::TestBody() Line 1606
	at C:\lib\opencv\modules\core\test\test_arithm.cpp(1606)
opencv_test_cored.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object, void(testing::Test::*)() method, const char * location) Line 3904
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(3904)
opencv_test_cored.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object, void(testing::Test::*)() method, const char * location) Line 3955
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(3955)
opencv_test_cored.exe!testing::Test::Run() Line 4000
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(4000)
opencv_test_cored.exe!testing::TestInfo::Run() Line 4173
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(4173)
opencv_test_cored.exe!testing::TestCase::Run() Line 4288
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(4288)
opencv_test_cored.exe!testing::internal::UnitTestImpl::RunAllTests() Line 6663
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(6663)
opencv_test_cored.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object, bool(testing::internal::UnitTestImpl::*)() method, const char * location) Line 3904
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(3904)
opencv_test_cored.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object, bool(testing::internal::UnitTestImpl::*)() method, const char * location) Line 3955
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(3955)
opencv_test_cored.exe!testing::UnitTest::Run() Line 6271
	at C:\lib\opencv\modules\ts\src\ts_gtest.cpp(6271)
opencv_test_cored.exe!RUN_ALL_TESTS() Line 22230
	at C:\lib\opencv\modules\ts\include\opencv2\ts\ts_gtest.h(22230)
opencv_test_cored.exe!main(int argc, char * * argv) Line 10
	at C:\lib\opencv\modules\core\test\test_main.cpp(10)

You can post an issue