Cpp sample program addingimages.cpp fails in runtime

Program gives on execution time error:
Unhandled exception at 0x00007FF9C8FB441C in Project1.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0000005C20AFE9F0.

Previous remark was for static library use
Now I tried dynamic libraries using case, but got linker error.

Severity Code Description Project File Line Suppression State
Error LNK1107 invalid or corrupt file: cannot read at 0x390 Project1 C:\Users\Raivo\opencv\build\x64\vc15\bin\opencv_videoio_ffmpeg460_64.dll 1

Are you manually adding C:\Users\Raivo\opencv\build\x64\vc15\bin\opencv_videoio_ffmpeg460_64.dll as a link library?

Yes I added this library

Remove it and refer to my reply to your previous question

Now is new error

Severity Code Description Project File Line Suppression State
Error LNK1107 invalid or corrupt file: cannot read at 0x308 Project1 C:\Users\Raivo\opencv\build\x64\vc15\bin\opencv_videoio_msmf460_64.dll 1
  1. those are NOT meant to be linked directly, so remove it
    (the videoio module will load those dynamically, on its own)
  2. (again !) IF AT ALL, add .lib files to your linker, not .dll

Please read the last reply I gave you to your previous post

Please don’t create topics if you are not going spend the time to read the replies people make to them!

1 Like

I reality I added .lib files for linker. I don’t know, why it looks for dll-s.

there is no opencv_videoio_ffmpeg460_64.lib or opencv_videoio_msmf460_64.lib

Sorry. I am novice in this forum.
But I overcome this problem by installin opencv-4.6.0 from sources and it works fine

Also I have installed opencv-4.7.0 and learning its capabilities.

Version 4.7.0 don’t work properly. Libraries build gives error - Error C2001 newline in constant opencv_objdetect C:\Users\Raivo\opencv-4.7.0\build\modules\objdetect\opencl_kernels_objdetect.cpp 817

And both static library example gives memory allocation error and dynamic library using example gives error on linking -

Severity Code Description Project File Line Suppression State
Error LNK1107 invalid or corrupt file: cannot read at 0x368 Project1 C:\Users\Raivo\opencv-4.7.0\build\install\x64\vc17\bin\opencv_calib3d470.dll 1