# Error compiling face extra module

**URL:** <https://forum.opencv.org/t/error-compiling-face-extra-module/3294>\
**Category:** C++\
**Tags:** face, contrib, build\
**Created:** [May 11, 2021, 9:35pm UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294 "2021-05-11T21:35:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcosdo](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@marcosdo](https://forum.opencv.org/u/marcosdo)\
**Post date:** [May 11, 2021, 9:35pm UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294/1 "2021-05-11T21:35:08Z")

</div>

Hi, I’m Marcos, a student who is doing a university project using **Visual Studio 2019** with **c++** and your library (version **4.5.2** ). This is my first time using libraries, so I’ll try to describe my error as much accurate as I can. The project is about face recognition, so I’m trying the library with the example in the documentation:

> tutorial\_face\_main  
> I’m trying to use the first code, the one with EigenFaces.

For the installation, I downloaded the _opencv-4.5.2-vc14-vc15.exe_ from:

> [Release OpenCV 4.5.2 · opencv/opencv · GitHub](https://github.com/opencv/opencv/releases/tag/4.5.2)

And then, linked it with Visual Studio in three steps:

1. In (Settings-\> C+±\> General-\> Additional include directories) added _C:\opencv\build\include_.
2. In (Settings-\> Linker-\> General-\> Additional library directories) added _C:\opencv\build\x64\vc15\lib_.
3. In (Settings-\> Linker-\> Input) added _opencv\_world452.lib_ and _opencv\_world452d.lib_.
4. In (Compilation events-\> Post-compilation events) added the commad XCOPY “C:\opencv\build\x64\vc15\bin\*.dll” “$(TargetDir)” /D /K /Y, so the .dll could go to the .exe directory.

As I have to use the opencv/face.hpp, I downloaded the extra modules from:

> [Release 4.5.2 · opencv/opencv\_contrib · GitHub](https://github.com/opencv/opencv_contrib/releases/tag/4.5.2)  
> And I copied the _…opencv\_contrib-4.5.2\modules\face\include\opencv2_ archieves into _C:\opencv\build\include\opencv2_.

At this moment, I can use the functions in the _face_ files with autocomplete functionality and there are no red underlined parts. The problem is that when I compile the project, there are a lot of LNK2019 errors arising from the line **125**.

`Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();`

 ![Captura](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/9/93812086cc6a87f6ed340bbf3a559ee9c0957359.png)  
There is a screenshot.

I think the problem is about the **face** module, which maybe is not installed properly, because when I compile the code commenting the last section (from line **125** untill the end), there are no errors. but I looked for possible answers in forums and I didn’t get an useful answer.

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [May 12, 2021, 2:22am UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294/2 "2021-05-12T02:22:28Z")

</div>

Hi,  
face module is in opencv\_contrib.  
Did you build opencv with opencv\_contrib using cmake? it seems not(download opencv\_contrib is not enough)  
instructions are [here](https://github.com/opencv/opencv_contrib#readme)

---

<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:** [May 12, 2021, 6:14am UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294/3 "2021-05-12T06:14:43Z")

</div>

> [@marcosdo](#):
>
> At this moment, I can use the functions in the _face_ files with autocomplete functionality and there are no red underlined parts. The problem is that when I compile the project,

your IDE is fooling you, it does not work like this

you have to download the [opencv\_contrib repo](https://github.com/opencv/opencv_contrib/) and [rebuild it all from src](https://github.com/opencv/opencv_contrib/blob/master/README.md), before you can use the code.

---

<div class="post-metadata">

**Author:** ![marcosdo](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@marcosdo](https://forum.opencv.org/u/marcosdo)\
**Post date:** [May 12, 2021, 9:01am UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294/4 "2021-05-12T09:01:10Z")

</div>

It was that! It has been tough because i didn’t know how cmake works, but now I got it. I thought it wasn’t necessary do this as it wasn’t neccesary for the non-extra modules. Of course I was wrong! Thanks!

---

<div class="post-metadata">

**Author:** ![marcosdo](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@marcosdo](https://forum.opencv.org/u/marcosdo)\
**Post date:** [May 12, 2021, 9:02am UTC](https://forum.opencv.org/t/error-compiling-face-extra-module/3294/5 "2021-05-12T09:02:00Z")

</div>

It was that! Thanks a lot!
