MSDN的说明 Linker Tools Error LNK2022 metadata operation failed (HRESULT) : error_messageThe linker detected an error while merging metadata. The metadata errors must be resolved to link successfully.One reason for LNK2022 is when a struct exists in multiple modules with the same name, but with conflicting definitions, and when you compile with /clr. 你可能有重定义的结构,感觉与LN2005有同样的问题(LN2005是函数重定义) 你可以参考关于LN2005的解决办法http://community.csdn.net/Expert/topic/4035/4035191.xml?temp=.8737604
Symptoms When you declare anonymous structures globally and then compile the structures as managed code, you may receive the following (or similar) linker error messages: error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types ($ArrayType$0x1078d980): (0x02000002). LINK : fatal error LNK1255: link failed because of metadata errors Cause This behavior occurs because the compiler generated incorrect metadata for these anonymous structures. Resolution To resolve this problem, add unique identifiers when you use Managed Extensions for C++ so that you avoid using anonymous structures as global variables. Status Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.More Information The following code demonstrates the problem: //c1.cpp //Compiler option required: /clr struct { int i; }a1[] = { {1}, {2}, {3}, {4} }; void FuncA(int i) { a1[i].i = i; } //End of c1.cpp//c2.cpp<BR/> //Compiler option required: /clr struct { int i,k; } a2[] = { {1,2}, {3,4}, {4,5}, {5,6} }; void FuncA(int);void main() { FuncA(a2[1].k); } //End of c2.cpp
最新发现我终于找到重定义的POSITIN的地方了 在DirectShow 的自带文件wxlist.h中有这么几行 大家帮我看看是怎么回事 /* This definition is the same as the POSITION type for MFCs, so we must */ avoid defining it twice.
Linker Tools Error LNK2022
metadata operation failed (HRESULT) : error_messageThe linker detected an error while merging metadata. The metadata errors must be resolved to link successfully.One reason for LNK2022 is when a struct exists in multiple modules with the same name, but with conflicting definitions, and when you compile with /clr.
你可能有重定义的结构,感觉与LN2005有同样的问题(LN2005是函数重定义)
你可以参考关于LN2005的解决办法http://community.csdn.net/Expert/topic/4035/4035191.xml?temp=.8737604
When you declare anonymous structures globally and then compile the structures as managed code, you may receive the following (or similar) linker error messages: error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types ($ArrayType$0x1078d980): (0x02000002).
LINK : fatal error LNK1255: link failed because of metadata errors Cause
This behavior occurs because the compiler generated incorrect metadata for these anonymous structures. Resolution
To resolve this problem, add unique identifiers when you use Managed Extensions for C++ so that you avoid using anonymous structures as global variables. Status
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.More Information
The following code demonstrates the problem: //c1.cpp
//Compiler option required: /clr
struct { int i; }a1[] = { {1}, {2}, {3}, {4} };
void FuncA(int i) { a1[i].i = i; }
//End of c1.cpp//c2.cpp<BR/>
//Compiler option required: /clr
struct { int i,k; } a2[] = { {1,2}, {3,4}, {4,5}, {5,6} };
void FuncA(int);void main() {
FuncA(a2[1].k);
}
//End of c2.cpp
*/ avoid defining it twice.
#ifndef __AFX_H__
struct __POSITION { int unused; };
typedef __POSITION* POSITION;
#endif