The Link error during compilation is as follows: Mysax2handler. OBJ: Error lnk2005: "public: _ thiscall attributedetails: attributedetails (class attributedetails const &)"(?? 0attributedetails @ Qae @ abv0 @ Z) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "public: _ thiscall childdetails: childdetails (class childdetails const &)"(?? 0childdetails @ Qae @ abv0 @ Z) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "public: _ thiscall elementdetails: elementdetails (class elementdetails const &)"(?? 0elementdetails @ Qae @ abv0 @ Z) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "public: Class elementdetails _ thiscall elementdetails: Operator = (class elementdetails const &)"(?? 4elementdetails @ Qae? Av0 @ abv0 @ Z) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "int _ cdecl run (class STD: basic_string <char, struct STD: char_traits <char>, class STD: Allocator <char>) "(? Run @ yahv? $ Basic_string @ du? $ Char_traits @ d @ STD @ V? $ Allocator @ d @ 2 @ STD @ Z) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "class STD: Map <class STD: basic_string <char, struct STD: char_traits <char>, class STD: Allocator <char>, class elementdetails, struct STD: less <class STD: basic_string <char, struct STD: char_traits <char>, class STD: Al Locator <char >>>, class STD: Allocator <class elementdetails> elementlist "(? Elementlist @ 3 V? $ Map @ V? $ Basic_string @ du? $ Char_traits @ d @ STD @ V? $ Allocator @ d @ 2 @ STD @ velementdetails @ u? $ Less @ V? $ Basic_string @ du? $ Char_traits @ d @ STD @ V? $ Allocator @ d @ 2 @ std@@@ 2 @ V? $ Allocator @ velementdetails @ 2 STD @) Already defined in usesax. OBJ Mysax2handler. OBJ: Error lnk2005: "class STD: Stack <class stackentry, class STD: deque <class stackentry, class STD: Allocator <class stackentry> elementstack "(? Elementstack @ 3 V? $ Stack @ vstackentry @ V? $ Deque @ vstackentry @ V? $ Allocator @ vstackentry@@@ STD @) Already defined in usesax. OBJ .. \ Bin/dtd.exe: Fatal er Found from csdn: Lnk2005 errors are often encountered in programming-repeated definition errors. In fact, lnk2005 errors are not very difficult to solve. Find out the cause of its formation, and you can easily solve it. Lnk2005 errors may occur in the following situations: 1. Define global variables repeatedly. There may be two situations: A. For some beginner ProgrammingProgramStaff, sometimes think that you can use definitions to declare where you need to use global variables. In fact, this is wrong. global variables are for the entire project. The correct definition should be defined in a CPP file as follows: int g_test; in the CPP file in use, use: extern int g_test. If you still use int g_test, the lnk2005 error will be generated. The error message is similar to AAA. OBJ error lnk2005 int book C? Book @ 3ha already defined in BBB. obj. Remember that you cannot assign values to variables. Otherwise, the lnk2005 error will still occur. What we need here is a "Declaration", not a "Definition "! According to the C ++ standard, a variable is declared and must satisfy both conditions. Otherwise, it is defined as follows: (1) The declaration must use the extern keyword; (2) the variable cannot be assigned an initial value. Therefore, the following is a statement: Extern int; The following is the definition Int A; int A = 0; extern int A = 0; B. For programmers who are not so rigorous in programming, they always define a global variable in files that require variables, and do not consider the variable name, this often leads to repeated variable names and lnk2005 errors. 2. Duplicate header files. The header files that need to be included include definitions of variables, functions, and classes, and must be included multiple times in other places, if there are no related Macros in the header file and other measures to prevent duplicate links, the lnk2005 error will occur. The solution is to perform similar processing in the header file to be included: # ifndef my_h_file // if this macro is not defined # Define my_h_file // define this macro ....... // Header file body content ....... # Endif The above is done using macros. You can also use pre-compilation to add the following to the header file: # Pragma once // Header file subject 3. Use a third-party library. This situation is mainly caused by library conflicts between the function library and the MFC in the C runtime. The specific method is to put the database that prompts an error in front of another database. In addition, selecting different C function libraries may cause this error. Microsoft and C have two types of runtime function libraries: libc. Lib, which does not support multithreading. The other is multi-threaded: msvcrt. Lib. This error may occur if these two function libraries are used together in a project. In general, it requires the library of MFC to be linked before the function library of C runtime, we recommend that you use msvcrt that supports multiple threads. lib. Therefore, before using a third-party library, you must first know which library it is linked to. Otherwise, the lnk2005 error may occur. If you have to use a third-party library, you can try to modify it as described below, but it cannot be guaranteed to solve the problem. The first two methods are provided by Microsoft: A. Select VC menu project-> Settings-> link-> catagory and select input. Then, enter the library you want to ignore in the edit column of ignore libraries, for example, nafxcwd. LIB; libcmtd. lib. Then fill in the correct library order in the edit column of Object/library modules. here you need to be able to determine what is the correct order! B. Select the VC menu project-> Settings-> link page, and enter/verbose: Lib in the edit column of project options, in this way, you can see the link sequence in the output window during the compilation of the link program. C. Select the VC menu project-> Settings-> C/C ++ page, select code generation for catagory, and then select other libraries such as multithread DLL in user runtime libraray to try them one by one. For more information about the compiler processing process, see: Http://www.donews.net/xzwenlan/archive/2004/12/23/211668.aspx This is one of the several lnk2005 errors I have encountered. There are certainly other situations that may also cause such errors, so I don't want you to read this articleArticleWhen we encounter lnk2005 errors in the future, we don't have to worry about troubleshooting the number. The process of programming is a process of thinking, so you can start your mind more and get more! Found from someone's blog: 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! The first situation mentioned in csdn was encountered, but I learned how to solve the problem using a blog solution... |