opencv test on host machine

I read below text.

https://devtalk.nvidia.com/default/topic/1071460/faq/opencv-compile-opencv-4-1-1-on-drive-software-10-0/post/5429890/#5429890

following this, I installs opencv 4.1.1 after then try to test some example code like this
(very simple code for draw picture file)

################################################################################
#include
#include <opencv2/opencv.hpp>

int main()
{
std::cout << "OpenCV Version : " << CV_VERSION << std::endl;
cv::Mat img;
cv::namedWindow(“EXAMPLE01”, CV_WINDOW_AUTOSIZE);

img = cv::imread("cat.jpg", CV_LOAD_IMAGE_COLOR);
if (img.empty())
{
    std::cout << "[!] You can NOT see the cat!" << std::endl;
    return -1;
}
cv::imshow("EXAMPLE01", img);
cv::waitKey(0);
cv::destroyWindow("EXAMPLE01");
return 0;

}
################################################################################

But, when I try to compile this test code using command,
g++ test.cpp -o test pkg-config --libs opencv

the error message is printed
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
test.cpp:2:10: fatal error: opencv2/opencv.hpp: No such file or directory
#include <opencv2/opencv.hpp>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.

I searched this error message, and I found some reasons.
In opencv 4.x, It does not make opencv.pc file but opencv4.pc.
So I try to use another compile option like this,
g++ test.cpp -o test pkg-config --cflags --libs opencv4
but it doesn’t work also
(also, I edited my ~/.bashrc file. I added some lines for adding Env. variable about PKG_CONFIG_PATH.
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
export PKG_CONFIG_PATH

note: I changeed camke option to ‘-DCMAKE_INSTALL_PREFIX=/usr/local’ because I want to put opencv4.pc file to /usr/local/lib/pkgconfig)

test.cpp: In function ‘int main()’:
test.cpp:9:9: error: ‘namedWindow’ is not a member of ‘cv’
cv::namedWindow(“EXAMPLE01”, CV_WINDOW_AUTOSIZE);
^~~~~~~~~~~
test.cpp:9:34: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
cv::namedWindow(“EXAMPLE01”, CV_WINDOW_AUTOSIZE);
^~~~~~~~~~~~~~~~~~
test.cpp:9:34: note: suggested alternative: ‘CV_MINOR_VERSION’
cv::namedWindow(“EXAMPLE01”, CV_WINDOW_AUTOSIZE);
^~~~~~~~~~~~~~~~~~
CV_MINOR_VERSION
test.cpp:11:33: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
img = cv::imread(“cat.jpg”, CV_LOAD_IMAGE_COLOR);
^~~~~~~~~~~~~~~~~~~
test.cpp:11:33: note: suggested alternative: ‘CV_HAL_DFT_STAGE_COLS’
img = cv::imread(“cat.jpg”, CV_LOAD_IMAGE_COLOR);
^~~~~~~~~~~~~~~~~~~
CV_HAL_DFT_STAGE_COLS
test.cpp:17:9: error: ‘imshow’ is not a member of ‘cv’
cv::imshow(“EXAMPLE01”, img);
^~~~~~
test.cpp:18:9: error: ‘waitKey’ is not a member of ‘cv’
cv::waitKey(0);
^~~~~~~
test.cpp:18:9: note: suggested alternative: ‘write’
cv::waitKey(0);
^~~~~~~
write
test.cpp:19:9: error: ‘destroyWindow’ is not a member of ‘cv’
cv::destroyWindow(“EXAMPLE01”);
^~~~~~~~~~~~~

I think this error message means that compiler does not find opencv package.

How to fix this problem?