是什么导致VS2013错误LNK2005:__xi_a已在MSVCRT.lib(cinitexe.obj)中定义? [英] What is causing VS2013 error LNK2005: __xi_a already defined in MSVCRT.lib(cinitexe.obj)?

查看:416
本文介绍了是什么导致VS2013错误LNK2005:__xi_a已在MSVCRT.lib(cinitexe.obj)中定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案昨天建立.今天,除了更改 .hpp .cpp 文件外,什么都没有.

My solution built yesterday. Today after changing nothing but .hpp and .cpp files it doesn't.

Visual Studio 2013中的完整错误文本(使用2013年11月CTP):

The full error text from Visual Studio 2013 (Using the November 2013 CTP):

Error   1   error LNK2005: __xi_a already defined in MSVCRT.lib(cinitexe.obj)   C:\Users\drtwox\dev\repos\game\trunk\engine\game\LIBCMT.lib(crt0init.obj)   game
Error   2   error LNK2005: __xi_z already defined in MSVCRT.lib(cinitexe.obj)   C:\Users\drtwox\dev\repos\game\trunk\engine\game\LIBCMT.lib(crt0init.obj)   game
Error   3   error LNK2005: __xc_a already defined in MSVCRT.lib(cinitexe.obj)   C:\Users\drtwox\dev\repos\game\trunk\engine\game\LIBCMT.lib(crt0init.obj)   game
Error   4   error LNK2005: __xc_z already defined in MSVCRT.lib(cinitexe.obj)   C:\Users\drtwox\dev\repos\game\trunk\engine\game\LIBCMT.lib(crt0init.obj)   game
Error   7   error LNK1169: one or more multiply defined symbols found   C:\Users\drtwox\dev\repos\game\trunk\engine\build\x64\Test\game.exe 1   1   game

大约和戳戳一样有用...

About as useful as a poke in the eye...

此答案这个类似的问题说:

This answer to this similar question says:

您正在混合使用/MD编译的代码(使用DLL版本的 CRT)和使用/MT编译的代码(使用静态CRT库). 那行不通,所有源代码文件必须使用相同的文件进行编译 环境.假设您使用的是/MD预编译的库, 几乎总是正确的设置,您必须使用 此设置也是如此.

You are mixing code that was compiled with /MD (use DLL version of CRT) with code that was compiled with /MT (use static CRT library). That cannot work, all source code files must be compiled with the same setting. Given that you use libraries that were pre-compiled with /MD, almost always the correct setting, you must compile your own code with this setting as well.

我已经检查(并重新检查)该解决方案中的所有项目仍在使用相同的运行时库; Multi-threaded DLL用于发布,Multi-threaded Debug DLL用于调试.为确保确定,我已经完成了完整的解决方案重建.

I have checked (and rechecked) that all projects in the solution are still using the same runtime library; Multi-threaded DLL for Release and Multi-threaded Debug DLL for Debug. I've done a full solution rebuild just to be sure.

Subversion日志显示外部"目录,其中包含所有自2013年12月4日以来未修改的第三方库;一个月前.我检查了它们的配置并重新构建了它们.

The Subversion log shows the 'external' directory that contains all 3rd party libraries had not been modified since 2013-12-04; one month ago. I checked their configurations and rebuilt them anyway.

Subversion日志还显示,从昨天开始,只有现有的 .hpp .cpp 文件已被修改.没有添加新的库,没有包含新的外部头文件,也没有项目配置发生变化. 7个文件中有200多行更改的代码和新的代码.

The Subversion log also shows that only existing .hpp and .cpp files have been modified since yesterday. No new libraries have been added, no new external headers #included and no project configurations have changed. There are over 200 lines of changed and new code in 7 files.

可能是什么问题?

更新:编译器的日志: http://pastebin.com/aHJ5Xi2V

解决方案:问题不是不正确的/MT/MD编译器标志,这是GLEW库和缺少的#define GLEW_STATIC.我将GLEW项目设置更改为使用/Zl(忽略默认库名称),如此处所述:

Solution: The problem was not incorrect /MT /MD compiler flags, it was the GLEW library and a missing #define GLEW_STATIC. I changed the GLEW project settings to use /Zl (Omit Default Library Name) as documented here: http://msdn.microsoft.com/en-us/library/f1tbxcxh.aspx.

推荐答案

某些原因导致两个运行时都被链接.

Something is causing both runtimes to be linked in.

首先尝试(手动)清除项目创建的所有.obj和.lib文件,然后重新构建.

First try cleaning (manually) all .obj and .lib files that your project creates and rebuild it.

如果这样做没有帮助,请设置链接器的/VERBOSE标志(IDE中的链接器|常规|显示进度" =显示所有进度消息(/VERBOSE)").

If that doesn't help, set the linker's /VERBOSE flag ("Linker | General | Show Progress" = "Display all progress messages (/VERBOSE)" in the IDE).

然后查看输出;在IDE中,它将位于生成输出目录中名为<project-name>.log的文件中.

Then look at the output; in the IDE it'll be in the build output directory in a file called <project-name>.log.

您将看到在每个库中搜索的位置以及导致搜索该库的对象文件.

You'll see where each library is searched and what object file is causing the library to be searched.

更新:

日志输出显示,由于正在处理的一个或多个目标文件(可能是库中的目标文件)中的DEFAULTLIB指令,正在搜索LIBCMT.lib.

The log output shows that LIBCMT.lib is being searched due to a DEFAULTLIB directive in one or more of the object files being processed (which may be an object file from a library).

但是,从日志输出中我不清楚是哪个输入负责-我认为它是glew32s.lib(其中的glew.obj对象).

However, it's not clear to me form the log output which input(s) is responsible - I think it's glew32s.lib (the glew.obj object in it).

请参见此SO答案,以查找找到哪些.obj/.lib文件具有DEFAULTLIB的方法.指令.

See this SO answer for a way to find which .obj/.lib files have a DEFAULTLIB directive.

您可能会在项目属性(忽略特定的默认库")中设置/NODEFAULTLIB:libcmt.lib选项.

You might get away with setting the /NODEFAULTLIB:libcmt.lib option in the project properties ("Ignore Specific Default Libraries").

这篇关于是什么导致VS2013错误LNK2005:__xi_a已在MSVCRT.lib(cinitexe.obj)中定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆