A static library file provided by another colleague of the company was used in recent projects. This static library file integrates Cuda, OpenCL two libraries, for graphics acceleration calculation, improve video decoding stitching speed. However, when compiling a linked project, the VS burst has the following error:
1>libcmtd.lib (crt0init.obj): Error LNK2005: __XI_A has defined MSVCRT.lib (cinitexe.obj) in 1>libcmtd.lib (Crt0init.obj) : Error LNK2005: __xi_z already defined 1>libcmtd.lib (crt0init.obj) in MSVCRT.lib (cinitexe.obj): Error LNK2005: __xc_a already in MSVCRT. 1>libcmtd.lib (crt0init.obj) defined in Lib (cinitexe.obj): Error LNK2005: __xc_z already defined in MSVCRT.lib (cinitexe.obj)
The compile phase does not have an error, and judging by the VS output is a symbolic redefinition. However, the symbol "__XI_A" in the hint above does not appear in the source code. Therefore, the judgment may be the wrong version of the library. To view the property configuration of the project, right-click the project---Properties->c/c++-> code generation-run Library:
You can see that the main project uses a "multithreaded dll (/MD)" version of the runtime, while developing a static library with the configuration of "multithreaded Debugging (/MTD)":
Obviously, when compiling the link, an error occurs, resulting in an inability to generate the executable program properly. The problem is resolved by setting the version of the Static library project and the runtime Library of the master project to be consistent. In addition, there is a new way to view the specific static library path of the project link: select it in the show progress, general, properties------linker.
Reference links
1. Http://stackoverflow.com/questions/5249431/linker-trouble-how-to-determine-where-a-defaultlib-is-coming-from /16899011#16899011
2. http://stackoverflow.com/questions/20918729/ What-is-causing-vs2013-error-lnk2005-xi-a-already-defined-in-msvcrt-libcinit
3. http://stackoverflow.com/questions/2728649/error-lnk2005-xxx-already-defined-in-msvcrt-libmsvcr100-dllc-something-libc
vs Compile Link-time errors (Error Link2005) workaround