Linux build with cmake problem: pkg-config: Package opencv was not found

I am new to Opencv. Installing in python worked fine, but the c++ installation had problems and I don’t know how to fix them.

I followed this tutorial: OpenCV: Using OpenCV with Eclipse (plugin CDT)
In eclipse, I manually entered the library items, but it did nothing.

the pkg-config command returned this error:

pkg-config --cflags --libs opencv
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘opencv’ found

The same happened with opencv2 and opencv4.
How do I fix this?
Thank you