How can I compile openCV with Cygwin

Struggling a lot here, google probably all web sites but still can not find the solution.
Kindly assist!

$ gcc -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test  main.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui

 gcc -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test  main.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:/home/inbox/main.cpp:35: undefined reference to `std::allocator<char>::allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `main':
/home/inbox/main.cpp:35: undefined reference to `std::allocator<char>::~allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:36: undefined reference to `cv::imread(cv::String const&, int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:93: undefined reference to `std::allocator<char>::allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:93: undefined reference to `std::allocator<char>::~allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:94: undefined reference to `cv::imread(cv::String const&, int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:160: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:227: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:227: undefined reference to `std::ostream::operator<<(int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:227: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:228: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:228: undefined reference to `std::ostream::operator<<(int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:228: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:231: undefined reference to `std::ostream::operator<<(int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:231: undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:250: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:250: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:250: undefined reference to `std::allocator<char>::~allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:81: undefined reference to `std::allocator<char>::~allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:250: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /home/inbox/main.cpp:250: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:/usr/include/opencv2/core/cvstd.inl.hpp:221: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `operator<< <int>':
/usr/include/opencv2/core/cvstd.inl.hpp:221: undefined reference to `std::ostream::operator<<(int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/include/opencv2/core/cvstd.inl.hpp:221: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/include/opencv2/core/cvstd.inl.hpp:221: undefined reference to `std::ostream::operator<<(int)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/include/opencv2/core/cvstd.inl.hpp:221: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZN2cv6StringD1Ev+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZN2cv3MatD1Ev+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNK2cv3Mat5cloneEv+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `cv::String::String(std::string const&)':
/usr/include/opencv2/core/cvstd.inl.hpp:80: undefined reference to `std::string::empty() const'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/include/opencv2/core/cvstd.inl.hpp:82: undefined reference to `std::string::size() const'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/include/opencv2/core/cvstd.inl.hpp:83: undefined reference to `std::string::c_str() const'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata+0x14): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata+0x128): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> >(char const*, std::allocator<char> const&)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.h:3663: undefined reference to `std::string::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt6vectorIN2cv6Point_IiEESaIS2_EEC1ESt16initializer_listIS2_ERKS3_+0x10): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt6vectorIN2cv6Point_IiEESaIS2_EED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt6vectorIS_IN2cv6Point_IiEESaIS2_EESaIS4_EEC1ESt16initializer_listIS4_ERKS5_+0x10): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt12_Vector_baseISt6vectorIN2cv6Point_IiEESaIS3_EESaIS5_EED2Ev+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt6vectorIS_IN2cv6Point_IiEESaIS2_EESaIS4_EED1Ev+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIN2cv6Point_IiEESaIS2_EED2Ev+0xc): more undefined references to `__gxx_personality_seh0' follow
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >::_S_check_init_len(unsigned long, std::allocator<cv::Point_<int> > const&)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/stl_vector.h:1770: undefined reference to `std::__throw_length_error(char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `std::vector<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > >::_S_check_init_len(unsigned long, std::allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > > const&)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/stl_vector.h:1770: undefined reference to `std::__throw_length_error(char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:600: undefined reference to `std::allocator<char>::allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:600: undefined reference to `std::allocator<char>::~allocator()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:601: undefined reference to `std::string::_S_empty_rep()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:601: undefined reference to `std::string::_Rep::_M_refdata()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:605: undefined reference to `std::__throw_logic_error(char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:610: undefined reference to `std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:612: undefined reference to `std::string::_Rep::_M_refdata()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:612: undefined reference to `std::string::_S_copy_chars(char*, char const*, char const*)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:618: undefined reference to `std::string::_Rep::_M_set_length_and_sharable(unsigned long)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/basic_string.tcc:619: undefined reference to `std::string::_Rep::_M_refdata()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `__gnu_cxx::new_allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > >::deallocate(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >*, unsigned long)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:145: undefined reference to `operator delete(void*, unsigned long)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `__gnu_cxx::new_allocator<cv::Point_<int> >::deallocate(cv::Point_<int>*, unsigned long)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:145: undefined reference to `operator delete(void*, unsigned long)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `__gnu_cxx::new_allocator<cv::Point_<int> >::allocate(unsigned long, void const*)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:116: undefined reference to `std::__throw_bad_array_new_length()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:117: undefined reference to `std::__throw_bad_alloc()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `__gnu_cxx::new_allocator<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > >::allocate(unsigned long, void const*)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:116: undefined reference to `std::__throw_bad_array_new_length()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/ext/new_allocator.h:117: undefined reference to `std::__throw_bad_alloc()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o: in function `std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >* std::__uninitialized_copy<false>::__uninit_copy<std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > const*, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >*>(std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > const*, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > > const*, std::vector<cv::Point_<int>, std::allocator<cv::Point_<int> > >*)':
/usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/stl_uninitialized.h:95: undefined reference to `__cxa_begin_catch'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/stl_uninitialized.h:98: undefined reference to `__cxa_rethrow'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/stl_uninitialized.h:95: undefined reference to `__cxa_end_catch'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt20__uninitialized_copyILb0EE13__uninit_copyIPKSt6vectorIN2cv6Point_IiEESaIS5_EEPS7_EET0_T_SC_SB_+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZSt10_ConstructISt6vectorIN2cv6Point_IiEESaIS3_EEJRKS5_EEvPT_DpOT0_+0x10): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt6vectorIN2cv6Point_IiEESaIS2_EEC1ERKS4_+0x10): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIN2cv6Point_IiEESaIS2_EEC2EmRKS3_+0xc): undefined reference to `__gxx_personality_seh0'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.rdata$.refptr._ZNSt8ios_base4InitD1Ev[.refptr._ZNSt8ios_base4InitD1Ev]+0x0): undefined reference to `std::ios_base::Init::~Init()'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.rdata$.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_[.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]+0x0): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccSUyuRe.o:main.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined reference to `std::cout'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../lib/libcygwin.a(_cygwin_crt0_common.o):/usr/src/debug/cygwin-3.3.5-1/winsup/cygwin/lib/_cygwin_crt0_common.cc:78: undefined reference to `operator new(unsigned long)'
collect2: error: ld returned 1 exit status

what are you trying to achieve here ?
os ? opencv version ? exact compiler ?
(it somehow looks, like the opencv libs you try to use (where are those from ?) do not match your current environment)

it works now! I just need to use g++ instead of gcc…
New case:
Could not compile opencv header

#include "opencv2/core.hpp"
#include <cstdio>
#include <ctime>
#include <opencv/dnn.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/core/utils/trace.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <time.h>
#include <vector>

    using namespace std;
    using namespace cv;

    int main() {


            HWND hwndDesktop = GetDesktopWindow ();
            int key = 0;
            int frame_width = 1920;
            int frame_height = 1080;

            VideoWriter video ("screenCap.avi", VideoWriter::fourcc ('M', 'J', 'P', 'G'), 15, Size
        (frame_width, frame_height));

            while (key != 27)
            {
                Mat hwnd2mat(HWND hwnd);
                Mat src = hwnd2mat (hwndDesktop);
                Mat dst;

                cvtColor (src, dst, COLOR_BGRA2RGB);

                video.write (dst);
                imshow ("Screen Capture", dst);
                key = waitKey (27);
            }
            video.release ();
            destroyAllWindows ();
            return 0;

        }

g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ capScreen main.cpp -lopencv_core -lopencv_imgproc opencv_highgui

Error output:
main.cpp:1:10: fatal error: opencv/dnn.hpp: No such file or directory
1 | #include <opencv/dnn.hpp>
| ^~~~~~~~~~~~~~~~

Using Windows10/Cygwin/ggc/fresh opencv
I’ve installed ffmpeg, still nothing

make sure the -I paths contain something that contains opencv/dnn.hpp

related:

It compiles for rest headers, problem only with dnn

#include <opencv2/dnn.hpp>