vs Compile Link-time errors (Error Link2005) workaround

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.