# OpenCV and UE4 link error

**URL:** https://forum.opencv.org/t/opencv-and-ue4-link-error/10713
**Category:** C++
**Tags:** build
**Created:** [October 27, 2022, 4:49pm UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713 "2022-10-27T16:49:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![VBD\_Unit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vbd_unit/32/6353_2.png) [@VBD\_Unit](https://forum.opencv.org/u/VBD_Unit)
#### Post date: [October 27, 2022, 4:49pm UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/1 "2022-10-27T16:49:12Z")

</div>

Hello! I’m trying to connect OpenCV to my UnrealEngine 4 project. I was able to overcome collisions in the utility.hpcc file according to [this manual](https://www.youtube.com/watch?v=YOidIl2kTD0) and write the necessary directories for lib files and C++ headers in the .Build.cs file. The project compiles and runs, I can work with the Mat class and read images using the imread function. But when I try to use the imwrite function, I get an link errors LNK2019 and LNK2001 about _bool \_\_cdecl cv::imwrite(…_ I tried using versions 3.4 and 4.6, but the error is repeated.

Please tell me how can I deal with this problem. Sorry for bad English.

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [October 27, 2022, 8:03pm UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/2 "2022-10-27T20:03:09Z")

</div>

> [@VBD\_Unit](#):
>
> I get an link errors LNK2019 and LNK2001 about _bool \_\_cdecl cv::imwrite(…_

complete error messages are required. please review the [MRE](https://stackoverflow.com/help/minimal-reproducible-example) article.

---

<div class="post-metadata">

### Author: ![VBD\_Unit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vbd_unit/32/6353_2.png) [@VBD\_Unit](https://forum.opencv.org/u/VBD_Unit)
#### Post date: [October 27, 2022, 9:10pm UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/3 "2022-10-27T21:10:22Z")

</div>

```auto
Error LNK2019 ссылка на неразрешенный внешний символ "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@ Z) в функции "public: bool__cdecl RHFragmentAlignerBufferInfo::TrySetData(struct RHUpdatePointCloudResult,class rs2::video_frame,class rs2::depth_frame)" (?TrySetData@RHFragmentAlignerBufferInfo@@QEAA_NUR HUpdatePointCloudResult@@Vvideo_frame@rs2@@Vdepth_ frame@4@@Z). ScanProj E:\ScanProj\Intermediate\ProjectFiles\ScannerHolog ram2.cpp.obj 1

Error LNK2001 неразрешенный внешний символ "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits @D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@ Z). ScanProj E:\ScanProj\Intermediate\ProjectFiles\ScannerHolog ram2.gen.cpp.obj 1

Error LNK1120 неразрешенных внешних элементов: 1 ScanProj E:\ScanProj\Binaries\Win64\UE4Editor-ScanProj-Win64-DebugGame.dll 1

Error MSB3073 выход из команды ""C:\Program Files\Epic Games\UE_4.27\Engine\Build\BatchFiles\Build.bat" ScanProjEditor Win64 DebugGame -Project="E:\ScanProj\ScanProj.uproject" -WaitMutex -FromMsBuild" с кодом 6. ScanProj C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\M icrosoft.MakeFile.Targets 44

```

I think i have a uncompatible version of OpenCV. But what version is compatible?

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [October 28, 2022, 12:39am UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/4 "2022-10-28T00:39:38Z")

</div>

did you link the `highgui` module too? that contains `cv::imshow`

---

<div class="post-metadata">

### Author: ![VBD\_Unit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vbd_unit/32/6353_2.png) [@VBD\_Unit](https://forum.opencv.org/u/VBD_Unit)
#### Post date: [October 28, 2022, 8:56am UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/5 "2022-10-28T08:56:57Z")

</div>

Thanks, but thats not work, simillar error:

```auto
1>ScannerHologram2.cpp.obj : error LNK2019: ссылка на неразрешенный внешний символ "bool __cdecl cv::imwrite(class cv::String const &,class cv::_InputArray const &,class std::vector<int,class std::allocator<int> > const &)" (?imwrite@cv@@YA_NAEBVString@1@AEBV_InputArray@1@AEBV?$vector@HV?$allocator@H@std@@@std@@@Z) в функции "public: bool__cdecl RHFragmentAlignerBufferInfo::TrySetData(struct RHUpdatePointCloudResult,class rs2::video_frame,class rs2::depth_frame)" (?TrySetData@RHFragmentAlignerBufferInfo@@QEAA_NURHUpdatePointCloudResult@@Vvideo_frame@rs2@@Vdepth_frame@4@@Z).
1>ScannerHologram2.gen.cpp.obj : error LNK2001: неразрешенный внешний символ "bool __cdecl cv::imwrite(class cv::String const &,class cv::_InputArray const &,class std::vector<int,class std::allocator<int> > const &)" (?imwrite@cv@@YA_NAEBVString@1@AEBV_InputArray@1@AEBV?$vector@HV?$allocator@H@std@@@std@@@Z).
1>ScannerHologram2.cpp.obj : error LNK2019: ссылка на неразрешенный внешний символ "void __cdecl cv::imshow(class cv::String const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBVString@1@AEBV_InputArray@1@@Z) в функции "public: bool__cdecl RHFragmentAlignerBufferInfo::TrySetData(struct RHUpdatePointCloudResult,class rs2::video_frame,class rs2::depth_frame)" (?TrySetData@RHFragmentAlignerBufferInfo@@QEAA_NURHUpdatePointCloudResult@@Vvideo_frame@rs2@@Vdepth_frame@4@@Z).
1>ScannerHologram2.gen.cpp.obj : error LNK2001: неразрешенный внешний символ "void __cdecl cv::imshow(class cv::String const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBVString@1@AEBV_InputArray@1@@Z).
1>E:\ScanProj\Binaries\Win64\UE4Editor-ScanProj-Win64-DebugGame.dll : fatal error LNK1120: неразрешенных внешних элементов: 2

```

My test code:

```auto
Mat im_src = cv::imread("D:\\test.png");
if (im_src.empty())
	return true;
imshow("image", im_src); //:(
imwrite("image.png", im_src); //:(

```

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [October 28, 2022, 12:43pm UTC](https://forum.opencv.org/t/opencv-and-ue4-link-error/10713/6 "2022-10-28T12:43:38Z")

</div>

imread and imwrite require the `imgcodecs` module. make sure to use the correct name for the thing. I don’t know the exact name. might be libopencv\_imgcodecs460 or whatever

if that still doesn’t work, you’re doing it wrong. either the wrong library (module) name or you failed to tell the compiler _where_ those files are.
