以下是截取一段,原文地址:http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/9abfefe0-56bd-4a82-ae14-b08f262972bd
I once handled a similar case in newsgroups. That case exhibit a almost same symptom. Please check out my summary below:
Problem
In that case, the customer has a DLL project that you had built on a machine where VS 2008 SP1 was installed. You then attempted to rebuild that project on a machine without SP1, and got a fatal compiler error C1900 “IL mismatch between ‘P1’ version ‘20080116’ and ‘P2’ version ‘20070207’”, and then LNK1257 “Code generation failed”. He found that rebuilding your static library alleviated the errors, but cannot accept this as a workaround because your clients will not have the ability to rebuild the libraries you distribute before they use them.
Cause(原因)
You had built the static library with the /GL (Whole Program Optimization) compiler switch, which requires Link Time Code Generation (/LTCG) when the static library is subsequently linked. These features require that all linked modules be built by the same version of the compiler. In fact, if precompiled headers are used, the same machine must build and link all the involved object code. Therefore, it is highly recommended that static libraries not be built with the /GL switch, since their intended use is quite frequently to support reuse by others.
Solution
You rebuilt the static library on your VS2008 SP1 machine without the /GL switch, and you no longer encounter this problem.
Please let me know if this info is helpful to you or not.
这里的解决方法是,将项目属性—C/C++—optimization(优化)—Whole Program Optimization(全程序优化)关掉。
对我遇到的情况,适用。
本文总结了一位用户在使用VS2008 SP1构建DLL项目时遇到的问题,即在未安装SP1的机器上重建项目时出现的C1900和LNK1257错误。问题的原因在于使用了/GL(全程序优化)编译器选项,解决方案是关闭此选项。
1376

被折叠的 条评论
为什么被折叠?



