qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”


遇到的编译失败问题如下:

1>qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”(ChangePWDdia.obj 中)
1>qtmain.lib(qtmain_win.obj) : error LNK2019: 无法解析的外部符号 “__declspec(dllimport) void __cdecl std::_Xbad_alloc(void)” (_imp[email protected]@@YAXXZ),该符号在函数 “char * __cdecl std::_Allocate(unsigned int,char *)” (??KaTeX parse error: Expected group after '_' at position 93: …19: 无法解析的外部符号 "_̲_declspec(dllim…[email protected]?chartraits@D@std@@V?[email protected]@[email protected]@V?[email protected]@[email protected]@[email protected]@Z) 中被引用
1>C:\ChipSort-all- 1123 -更新\Win32\Release\ChipSort_KDS.exe : fatal error LNK1120: 3 个无法解析的外部命令
1>
1>生成失败。

分析可知,qtmain.lib是vs2013编译出来的,而我现在编译使用的是vs2010,才导致这个问题的出现。( 因为值“1800”对应VS2013,值“1600”对应VS2010)

此时需要安装支持vs2010的qt的版本,在Qt Options中添加此版本,并在Qt Project Settings中改选新添加的版本,具体步骤如下:

(1)下载并安装qt-opensource-windows-x86-msvc2010_opengl-5.3.1.exe以及用于把QT插入VS中的插件qt-vs-addin-1.2.5.exe(不确定是不是1.2.5这个版本了)。若已安装则跳过此步。
qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”
(2)在VS2010的Qt5 -> Qt Options中,添加新的Qt Version:vs2010qt5.3.1(命名任意),路径为上一步安装所选择的路径,具体到VS版本号的文件夹路径C:\Qt\Qt5.3.1\5.3\msvc2010_opengl(安装路径因人而异,不能出错,我的是在C盘)
qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”
qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”
(3)在VS2010的Qt5 ->Qt Project Settings中,将Properties选项卡的Version选择为vs2010qt5.3.1
qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”
(4)重新编译即可成功
qtmain.lib(qtmain_win.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1600”