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