[普通]vs2008以上编译器不能编译的解决办法

作者(passion) 阅读(1045次) 评论(0) 分类( c++)

本课程所有代码均采用vs2008编译,但有些小伙伴们使用的vs2010,vs2012,vs2013等等编译器,造成编译时出现了各式各样的错误,那么现在就为这些错误做一些简单的汇总,为了说明问


题,本次偶安装了vs2013,其他编译器以此类推,仿照修改即可。




拿之前的一个课程,天气预报的代码进行解说,用vs2013打开并重新编译,出现以下错误


1>------ 已启动全部重新生成:  项目: Weather, 配置: Debug Win32 ------

1>  stdafx.cpp

1>  WeatherDlg.cpp

1>d:\windows\documents\visual studio 2008\curriculum\weather\weather\weatherdlg.cpp(302): warning C4018: “<”: 有符号/无符号不匹配

1>d:\windows\documents\visual studio 2008\curriculum\weather\weather\weatherdlg.cpp(319): warning C4018: “<”: 有符号/无符号不匹配

1>  Weather.cpp

1>  ServiceThread.cpp

1>  RenderEngine.cpp

1>d:\windows\documents\visual studio 2008\curriculum\weather\weather\renderengine.cpp(40): warning C4018: “>”: 有符号/无符号不匹配

1>  ParseJson.cpp

1>d:\windows\documents\visual studio 2008\curriculum\weather\weather\parsejson.cpp(75): warning C4018: “<”: 有符号/无符号不匹配

1>  OptionDlg.cpp

1>  ImageEx.cpp

1>  HttpWeather.cpp

1>  正在生成代码...

1>  json_writer.cpp

1>  json_value.cpp

1>  json_reader.cpp

1>  正在生成代码...

1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned 


int)" (?_invalid_parameter@@YAXPBG00II@Z) 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" 


(?_invoke_watson@@YAXPBG00II@Z) 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __call_reportfault 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler 已经在 libcmtd.lib(invarg.obj) 中定义

1>LIBCMT.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler 已经在 libcmtd.lib(invarg.obj) 中定义

1>LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

1>D:\windows\Documents\Visual Studio 2008\Curriculum\Weather\Debug\Weather.exe : fatal error LNK1169: 找到一个或多个多重定义的符号

========== 全部重新生成:  成功 0 个,失败 1 个,跳过 0 个 ==========



有不少链接时出现的问题,其中都是在****.lib中定义的错误,出现这种错误一般的解决办法是将前面的lib给忽略掉就行,不让他参与链接,比如这里的是就是忽略LIBCMT.lib


解决办法:项目属性-通用配置-链接器-输入-忽略特征默认库,此处在添加LIBCMT.lib即可解决问题




再次编译又出现以下错误:





1>------ 已启动生成:  项目: Weather, 配置: Debug Win32 ------

1>HttpWeather.obj : warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/SAFESEH”规范)

1>zlib.lib(inflate.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(crc32.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(infblock.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(adler32.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(zutil.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(infcodes.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(inftrees.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(infutil.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>zlib.lib(inffast.obj) : error LNK2026: 模块对于 SAFESEH 映像是不安全的。

1>D:\windows\Documents\Visual Studio 2008\Curriculum\Weather\Debug\Weather.exe : fatal error LNK1281: 无法生成 SAFESEH

 

映像。

========== 生成:  成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========




出现了fatal error LNK1281: 无法生成 SAFESEH映像。出现这种无法生成***的错误,一般就是不让他生成,当然大部分可以修改,有一些东西是不能这么修改的


解决办法:项目属性-通用配置-链接器-命令行 在其他选项的输入框中输入 /SAFESEH:NO 即可解决






如果你编译代码时还出现什么错误,请在下方留言,或者QQ告诉我,我会尽快解决


« 上一篇:城市热点dr.com5.2.0,5.2.1,6.0(D) 校园网客户端破解版(drcom至尊版)
« 下一篇:预编译头错误
在这里写下您精彩的评论
  • 微信

  • QQ

  • 支付宝

返回首页
返回首页 img
返回顶部~
返回顶部 img