模块不安全的 SAFESEH 图像 C + +

我正在使用 MicrosoftVisualStudio2011专业测试版

我试图运行 OpenCV C + + 文件(http://opencv.willowgarage.com/wiki/Welcome) ,我已经编译使用 cMake 和 Visual Studio 编译器。

然而,当我去调试这个项目时,我会得到600多个错误,其中大部分是:

错误 LNK2026: 模块对 SAFESEH 映像不安全。

显然,这些文件都在 opencv _ ffmpeg 项目中,但我找不到它们,我在微软的帮助页面上看了一下 safeseh 安全异常处理程序页面,但我找不到任何明确的答案。

我想知道是否有其他人有这个问题,如果他们设法解决它。

107288 次浏览

From the comments:

This happens when you link an .obj or .lib that contains code created by an earlier version of the compiler. Which of course would be common if you downloaded a binary for opencv_ffmpeg instead of the source. You can turn the linker option off but then you'll still have a CRT version incompatibility that can byte. Rebuild the library from source. – Hans Passant May 15 at 13:01  
 
Thanks for the help, it worked – Aaron Thompson May 17 at 14:50

Disabling option "Image has Safe Exception Handlers" in Project properties -> Configuration Properties -> Linker -> Advanced tab helped me.

Other way is to add some SEH handler (empty for example) to asm files and compile them with /safeseh option, then compile other code normally with /SAFESEH:YES compiler option.

Empty SEH handler:

.safeseh SEH_handler


SEH_handler   proc
;handler
ret


SEH_handler   endp

Your mileage may vary, but none of the above suggestions worked for me (although I did not try rolling my own asm exception handler).

What did work was to select build target Release/x64.

I am running Windows 10 on a 64-bit machine, and using Visual Studio 2015.

The target Release/Win32 works, too. I guess the main thing is to pick "Release".

If you got this error while building ZLIB in Visual Studio here is the solution. Look for contrib\masmx86\bld_ml32.bat and add /safeseh as a option

Before

ml /coff /Zi /c /Flmatch686.lst match686.asm
ml /coff /Zi /c /Flinffas32.lst inffas32.asm

After

ml /safeseh /coff /Zi /c /Flmatch686.lst match686.asm
ml /safeseh /coff /Zi /c /Flinffas32.lst inffas32.asm