My solution built yesterday. Today after changing nothing but .hpp and .cpp files it doesn't.
昨天我的解决方案构建。今天只改变了。hpp和。cpp文件。
The full error text from Visual Studio 2013 (Using the November 2013 CTP):
来自Visual Studio 2013的完整错误文本(使用2013年11月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:
这个类似问题的答案是:
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.
您将编译的代码(使用DLL版本的CRT)与用/MT(使用静态CRT库)编译的代码混合在一起。不能工作,所有的源代码文件必须用相同的设置编译。如果您使用的库是预先编译的/MD,几乎总是正确的设置,那么您必须使用这个设置来编译自己的代码。
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.
我已经检查(并重新检查)解决方案中的所有项目仍然使用相同的运行时库;用于发布的多线程DLL和用于调试的多线程调试DLL。我已经完成了一个完整的解决方案。
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日志显示了包含所有第三方库的“外部”目录自2013-12-04以来没有被修改;一个月前。我检查了他们的配置,然后重新组装。
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.
Subversion日志还显示,只有现有的.hpp和.cpp文件从昨天开始被修改。没有添加新的库,没有包含新的外部标题#,也没有更改项目配置。在7个文件中有超过200行更改和新代码。
What could be the problem?
有什么问题吗?
Update: The log from the compiler: http://pastebin.com/aHJ5Xi2V
更新:来自编译器的日志:http://pastebin.com/aHJ5Xi2V。
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.
解决方案:问题不是错误的/MT /MD编译器标志,它是GLEW库和一个缺失的#define GLEW_STATIC。我更改了GLEW项目设置,以使用/Zl(省略默认库名称),如下所示:http://msdn.microsoft.com/en-us/library/f1tbxcxh.aspx。
1 个解决方案
#1
3
Something is causing both runtimes to be linked in.
某些东西导致了两个运行时连接。
First try cleaning (manually) all .obj and .lib files that your project creates and rebuild it.
首先尝试(手动)清除项目创建并重新构建的所有.obj和.lib文件。
If that doesn't help, set the linker's /VERBOSE
flag ("Linker | General | Show Progress" = "Display all progress messages (/VERBOSE)" in the IDE).
如果这没有帮助,设置linker /VERBOSE标志(“linker | General | Show Progress”=“在IDE中显示所有进度消息(/VERBOSE)”)。
Then look at the output; in the IDE it'll be in the build output directory in a file called <project-name>.log
.
然后看看输出;在IDE中,它将在一个名为< projectname >.log. log的文件中构建输出目录。
You'll see where each library is searched and what object file is causing the library to be searched.
您将看到每个库的搜索位置,以及什么对象文件导致了要搜索的库。
Update:
更新:
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).
日志输出显示LIBCMT。由于一个或多个正在处理的对象文件(可能是来自库的对象文件),lib正在被搜索。
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).
但是,我不清楚输入的日志输出是什么,我认为是glew32。*(glew。obj对象)。
See this SO answer for a way to find which .obj
/.lib
files have a DEFAULTLIB
directive.
看看这个答案,找到一个。obj/。lib文件有一个DEFAULTLIB指令。
You might get away with setting the /NODEFAULTLIB:libcmt.lib
option in the project properties ("Ignore Specific Default Libraries").
您可以设置/NODEFAULTLIB:libcmt。项目属性中的lib选项(“忽略特定的默认库”)。
#1
3
Something is causing both runtimes to be linked in.
某些东西导致了两个运行时连接。
First try cleaning (manually) all .obj and .lib files that your project creates and rebuild it.
首先尝试(手动)清除项目创建并重新构建的所有.obj和.lib文件。
If that doesn't help, set the linker's /VERBOSE
flag ("Linker | General | Show Progress" = "Display all progress messages (/VERBOSE)" in the IDE).
如果这没有帮助,设置linker /VERBOSE标志(“linker | General | Show Progress”=“在IDE中显示所有进度消息(/VERBOSE)”)。
Then look at the output; in the IDE it'll be in the build output directory in a file called <project-name>.log
.
然后看看输出;在IDE中,它将在一个名为< projectname >.log. log的文件中构建输出目录。
You'll see where each library is searched and what object file is causing the library to be searched.
您将看到每个库的搜索位置,以及什么对象文件导致了要搜索的库。
Update:
更新:
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).
日志输出显示LIBCMT。由于一个或多个正在处理的对象文件(可能是来自库的对象文件),lib正在被搜索。
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).
但是,我不清楚输入的日志输出是什么,我认为是glew32。*(glew。obj对象)。
See this SO answer for a way to find which .obj
/.lib
files have a DEFAULTLIB
directive.
看看这个答案,找到一个。obj/。lib文件有一个DEFAULTLIB指令。
You might get away with setting the /NODEFAULTLIB:libcmt.lib
option in the project properties ("Ignore Specific Default Libraries").
您可以设置/NODEFAULTLIB:libcmt。项目属性中的lib选项(“忽略特定的默认库”)。