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

**URL:** <https://forum.opencv.org/t/link-error-when-link-with-opencv-api-cv-fastnlmeansdenoising-in-mac-pc/13549>\
**Category:** C++\
**Tags:** build\
**Created:** [June 16, 2023, 1:38am UTC](https://forum.opencv.org/t/link-error-when-link-with-opencv-api-cv-fastnlmeansdenoising-in-mac-pc/13549 "2023-06-16T01:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YingFeng](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/yingfeng/32/8098_2.png) [@YingFeng](https://forum.opencv.org/u/YingFeng)\
**Post date:** [June 16, 2023, 1:38am UTC](https://forum.opencv.org/t/link-error-when-link-with-opencv-api-cv-fastnlmeansdenoising-in-mac-pc/13549/1 "2023-06-16T01:38:56Z")

</div>

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);

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [June 16, 2023, 6:07am UTC](https://forum.opencv.org/t/link-error-when-link-with-opencv-api-cv-fastnlmeansdenoising-in-mac-pc/13549/2 "2023-06-16T06:07:14Z")

</div>

easy !  
[look at the docs](https://docs.opencv.org/4.x/d1/d79/group __photo__ denoise.html#ga0db3ea0715152e56081265014b139bec), 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 ?)

---

<div class="post-metadata">

**Author:** ![YingFeng](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/yingfeng/32/8098_2.png) [@YingFeng](https://forum.opencv.org/u/YingFeng)\
**Post date:** [June 16, 2023, 7:38am UTC](https://forum.opencv.org/t/link-error-when-link-with-opencv-api-cv-fastnlmeansdenoising-in-mac-pc/13549/3 "2023-06-16T07:38:46Z")

</div>

thank you, berak!  
it works! i just added -lopencv\_photo to link args.

thanks again!
