1 | initial version |
the compiler needs to be told where the header files ("include" directory) can be found.
the compiler also needs to know where the library files ("lib" directory) can be found.
where those are depends on how and where you installed OpenCV.
when you call g++ like that, you're responsible for everything. when you use cmake, cmake can find those things for you and construct a Makefile or other project file that contains this information.
to a beginner I would recommend using Python instead of C++. for python there's someone who has been providing a decently built module you can just install with "pip install opencv-python".