C语言error2005,关于ERROR LNK 2005错误

  • Post author:
  • Post category:其他


相信很多人对这个错误是一点也不陌生,甚至有些害怕,我也一样。其实自己遇到过这样的问题,也每次都解决了这样的问题,但关键是自己没总结,所以总是再遇到再改,很烦人,查资料也麻烦。现在有时间了总结下。

遇到问题我最喜欢F1,所以还是先看MSDN是怎么说的:

To fix by checking the following possible causes

1.Mixing static and dynamic libraries when also using /clr.

2.The symbol is a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that includesymbol.

3.The symbol is defined differently in two member objects in different libraries, and both member objects were used.

4.An absolute is defined twice, with a different value in each definition.

5.A header file declared and defined a variable. Possible solutions include:

·Declare the variable in .h:extern BOOL MyBool;and then assign to it in a .c or .cpp file:BOOL MyBool = FALSE;.

·Declare the var