C ++ classic error already defined in *****. OBJ Solution

Source: Internet
Author: User

My program is in the following shape: a header file. H, a main function. cpp, and an operation function. cpp. The operation function contains the header file, and the main function contains the operation function. cpp. An error occurs during running:

Symptoms:

Linking...
Xz. OBJ: Error lnk2005: "public: _ thiscall xz: xz (void )"(
?? 0xz @ Qae @ xz) Already defined in xzmain. OBJ
Xz. OBJ: Error lnk2005: "public: void _ thiscall xz: PDC (void )"(
? PDC @ xz @ qaexxz) Already defined in xzmain. OBJ
Xz. OBJ: Error lnk2005: "public: void _ thiscall xz: PCD (void )"(
? PCD @ xz qaexxz) Already defined in xzmain. OBJ
Xz. OBJ: Error lnk2005: "public: void _ thiscall xz: pzf (void )"(
? Pzf @ xz @ qaexxz) Already defined in xzmain. OBJ
Xz. OBJ: Error lnk2005: "public: _ thiscall xz ::~ Xz (void )"(
?? 1xz @ Qae @ xz) Already defined in xzmain. OBJ
Debug/xzmain.exe: Fatal error lnk1169: one or more multiply defined symbols found
An error occurred while executing link.exe.

Solution 1:

Change the operation function. cpp included in the main function to the header file. h, and then the above error can be solved.

Solution 2:

Re-open the compiler, re-open the file, and open the main function first. CPP, then compile and run, open FileView, where there is an external dependencies, put the header file. h, and operation functions. add CPP here to compile and run the main function. CPP. The program runs successfully!

 

 

Article transferred from: http://hi.baidu.com/3512/blog/item/d568bc340c002cb4d0a2d3d6.html

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.