# Linking issues static library in visual studio

**URL:** <https://forum.opencv.org/t/linking-issues-static-library-in-visual-studio/10055>\
**Category:** C++\
**Tags:** windows, build, imgcodecs\
**Created:** [September 2, 2022, 12:48pm UTC](https://forum.opencv.org/t/linking-issues-static-library-in-visual-studio/10055 "2022-09-02T12:48:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgd2022](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rgd2022](https://forum.opencv.org/u/rgd2022)\
**Post date:** [September 2, 2022, 12:48pm UTC](https://forum.opencv.org/t/linking-issues-static-library-in-visual-studio/10055/1 "2022-09-02T12:48:11Z")

</div>

Hello,

I would like to link the static library of OpenCv 4.6.0. Ihave downloaded the source and was capable with CMake to create the static library (opencv\_world460d.lib and opencv\_world460.lib). So I have an install folder with a folder include and folder x64/vc17/staticlib with the two lib files. So I asume that is all ok.  
I am using visual studio 2022 and first had a MFC dialog application (DLL based).  
But since I was not clear were my issues came from I made a simple console application that just displayed a simple image. To check if the was ok I first also build a DLL library from the same source to be sure that was all ok. Than went back to the static library.  
I made the required changes in the properties: VC++ directories: the path to the “static” include files, Linker-\>General-\> additional Library directories: the path to the static libraries,  
Linker-\>input-\>additional Dependencies (here debug and release resp: opencv\_world460d.lib and opencv\_world460.lib). And last one C/C+±\>code generation set to (debug resp release) /MTd and /MT.  
When I build the project I get 355 errors.

`LNK2019: unresolved external symbol opj_image_destroy referenced in function "public: void __cdecl cv::detail::OpjImageDeleter::operator()(struct opj_image *)const " (??ROpjImageDeleter@detail@cv@@QEBAXPEAUopj_image@@@Z), File C:\Users\rened\source\repos\TestOpeCvStaticLibr\TestOpeCvStaticLibr\opencv_world460d.lib(loadsave.obj)`

This error is than follwed by:

`LNK2001: unresolved external symbol opj_image_destroy, File C:\Users\rened\source\repos\TestOpeCvStaticLibr\TestOpeCvStaticLibr\opencv_world460d.lib(grfmt_jpeg2000_openjpeg.obj)`

Any one an idea what I am doing wrong?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![rgd2022](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rgd2022](https://forum.opencv.org/u/rgd2022)\
**Post date:** [September 14, 2022, 8:41am UTC](https://forum.opencv.org/t/linking-issues-static-library-in-visual-studio/10055/2 "2022-09-14T08:41:16Z")

</div>

I have includded all .lib files and now it seems to be ok. Only using the opencv\_world460(d).lib was probaly not enough.  
Regards.
