zl程序教程

您现在的位置是:首页 >  后端

当前栏目

“LNK2026 模块对于 SAFESEH 映像是不安全的“原因以及解决方法

方法安全模块 解决 以及 原因 对于 映像
2023-09-14 09:07:06 时间

今天在编译一个程序时,出现了“LNK2026 模块对于 SAFESEH 映像是不安全的”的错误,stackoverflow上解释原因如下:

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.

It can also be caused by, as the error states, modules for which the linker can’t find safe exception handlers. Assembly language modules in particular

就是说你链接了一个使用较早版本编译器生成的.lib或者.obj文件,或者找不到“safe exception handlers”,才会报这个错误。

解决方法如下:项目->项目属性->链接器->命令行,在右侧其他选项中添加“/SAFESEH:NO”,这样就不会再报错了。
在这里插入图片描述

有关更多SAFESEH的信息可以看这里

参考链接:

https://stackoverflow.com/questions/10599940/module-unsafe-for-safeseh-image-c

https://www.cnblogs.com/hanxi/archive/2012/06/10/2544230.html