C + + error:lnk2005 is already defined in *.obj

Source: Internet
Author: User

Problem


>>: Error lnk2005:xxxx (★★★★) already defined in ※※※.obj

Fatal error LNK1169: find one or more multi-definition symbols


"Possible causes."


When the first. cpp file that uses the header file generates. obj, int i is already defined. When another. cpp that uses this header file is once again [separately] generated. obj, int i is also defined. Then two obj is joined by another. CPP also include this header, and a duplicate definition will appear.



Solution

Typically, this variable is defined in the. h file, moved to a. cpp file, and an extern int ID is added to the CPP file that uses this variable.

C + + error:lnk2005 is already defined in *.obj

Related Article

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.