The most common 20 types of VC ++ compilation errors

Source: Internet
Author: User

1,Fatal error c1010: unexpected end of file while looking for precompiled header direve ve.

When searching for the pre-compiled header file path, the end of the file should not be encountered. (Generally no # include "stdafx. H ")

2,Fatal error c1083: cannot open include file: 'r ....... H': no such file or directory

You cannot open the file "r ....... H ": there is no such file or directory.

3,Error c2011: 'C ...... ': 'Class' type redefinition

Class "C ......" Redefinition.

4,Error c2018: unknown character '0xa3'

Unknown character '0xa3 '. (Generally Chinese characters or Chinese Punctuation Marks)

5. Error c2057: Expected constant expression

It is expected to be a constant expression. (Usually in the case Branch of the switch statement)

6,Error c2065: 'idd _ mydialog ': Undeclared identifier

"Idd_mydialog": Undeclared identifier.

7,Error c2082: redefinition of formal parameter 'breset'

The function parameter "breset" is redefined in the function body.

8,Error c2143: syntax error: Missing ': 'before '{'

Syntax error: ";" is missing before "{".

9,Error c2146: syntax error: Missing '; 'before identifier' DC'

Syntax error: ";" is lost before "DC".

10,Error c2196: Case value '69' already used

The Value 69 has been used. (Usually in the case Branch of the switch statement)

11,Error c2509: 'ontimer': member function not declared in 'chelloview'

The member function "ontimer" is not declared in "chelloview.

12,Error c2511: 'reset': overloaded member function 'void (INT) 'not found in' B'

The overloaded function "Void reset (INT)" cannot be found in class "B.

13,Error c2555: 'B: f1': overriding virtual function differs from 'A: f1' only by return type or calling convention

Class B's heavy load on function F1 of the same name in Class A is only based on the difference in the return value or call conventions.

14,Error c2660: 'settimer': function does not take 2 parameters

The "settimer" function does not pass two parameters.

15,Warning c4035: 'f ...... ': No Return Value

"F ......" The return statement does not return values.

16,Warning c4553: '=': operator has no effect; did you intend '= '?

The operator "=" with no effect; is it changed to "= "?

17. Warning c4700: local variable 'breset' used without having been initialized

The local variable "breset" is used without initialization.

18,Error c4716: 'cmyapp: initinstance': must return a value

The "cmyapp: initinstance" function must return a value.

19,Link: Fatal error lnk1168: cannot open debug/p1.exe for writing

Connection error: Unable to open the p1.exe file to rewrite the content. (P1.exe is still running, not closed)

20,Error lnk2001: unresolved external symbol "public: Virtual _ thiscall C ...... ::~ C ...... (Void )"

External symbols (variables, functions, etc.) that are not implemented are found during connection ).

 

Error: Error lnk2005 Solution

 

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...

 

 

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.