Link error when link with opencv api(cv::fastNlMeansDenoising) in Mac PC

i get a link error in mac, please help me:
Starting build…
/usr/bin/clang++ -std=c++11 -fcolor-diagnostics -fansi-escape-codes -g -I/usr/local/Cellar/opencv/4.7.0_4/include/opencv4 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++ /Users/zhengyingfeng/github/fingerprot/main.cpp -o /Users/zhengyingfeng/github/fingerprot/main -L/usr/local/Cellar/opencv/4.7.0_4/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_features2d -lopencv_imgcodecs
Undefined symbols for architecture x86_64:
“cv::fastNlMeansDenoising(cv::_InputArray const&, cv::_OutputArray const&, float, int, int)”, referenced from:
fingerprint::centralizing(cv::Mat) in main-88ef40.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Build finished with error(s).

  • The terminal process terminated with exit code: -1.
  • Terminal will be reused by tasks, press any key to close it.

more info:
i build the code in vs code, the tasks.json like below. If i remove cv::fastNlMeansDenoising from source code and still use other opencv api, everything is ok.

tasks.json
{
“tasks”: [
{
“type”: “cppbuild”,
“label”: “build_fingerprint”,
“command”: “/usr/bin/clang++”,
“args”: [
“-std=c++11”,
“-fcolor-diagnostics”,
“-fansi-escape-codes”,
“-g”,
“-I/usr/local/Cellar/opencv/4.7.0_4/include/opencv4”,
“-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++”,
{file}", "-o", "{fileDirname}/main”,
“-L/usr/local/Cellar/opencv/4.7.0_4/lib”,
“-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib”,
“-lopencv_core”,
“-lopencv_highgui”,
“-lopencv_imgproc”,
“-lopencv_features2d”,
“-lopencv_imgcodecs”
],
“options”: {
“cwd”: “${workspaceFolder}”,
},
“problemMatcher”: [
“$gcc”
],
“group”: “build”,

    }
],
"version": "2.0.0"

}

source code:
int imgN = fingerprint.rows;
int imgM = fingerprint.cols;
fingerprint.convertTo(fingerprint,CV_8UC1);
cv::Mat image;
cv::fastNlMeansDenoising(fingerprint, image, 3);
cv::Mat Gx, Gy;
cv::Sobel(image, Gx, CV_8U, 1, 0, 3);
cv::Sobel(image, Gy, CV_8U, 0, 1, 3);
cv::Mat orientnum, orientden;
cv::fastNlMeansDenoising(2 * Gx.mul(Gy), orientnum, 3);
cv::fastNlMeansDenoising(Gx.mul(Gx) - Gy.mul(Gy), orientden, 3);

easy !
look at the docs, notice it is in

#include <opencv2/photo.hpp>

aaaaaaaand add the opencv_photo lib …

(i mean, how did those other libs get into your list ?)

thank you, berak!
it works! i just added -lopencv_photo to link args.

thanks again!