OpenCV and UE4 link error

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 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.

complete error messages are required. please review the MRE article.

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?

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

Thanks, but thats not work, simillar error:

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:

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

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.