This article mainly introduces some common links in the VC6.0 development of the wrong solution, the need for friends can refer to the
(1) Error lnk2001:unresolved external symbol _main
No.: LNK2001
literal translation: unresolved external symbol: _main.
Error Analysis: The main function is missing. Check to see if the spelling or capitalization of main is correct.
(2) Error LNK2005: _main already defined in Xxxx.obj
Number: LNK2005
literal translation: _main already exists in Xxxx.obj. The direct reason for
error Analysis:
is that there are multiple (more than one) main functions in the program. This is the beginner C + + students in the first programming often make mistakes. This error is usually not that you include two main functions in the same file, but you include multiple CPP files in one project (project), and there is a main function in each CPP file. The process of triggering this error is typically this: you write a C + + program debugging, and then you are ready to write a second C + + file, so you may through the upper right corner of the close button to close the current CPP file Word window (or not closed, this operation does not affect the final result), Then a new CPP file is created from the menu or toolbar, in which the program is written, compiled, and then the error occurs. The reason is this: when you create the second CPP file, you do not close the original item, so you inadvertently add the new CPP file to the project where you were on the previous program. Switch to the File View view, expand the Source files node, and you will find two files.
When writing a C + + program, be sure to understand what Workspace is and what project is. Each program is a project, one project can be compiled into an application (*.exe), or a dynamic link library (*.dll). Typically, under each project, you can include multiple. cpp files,. h files, and other resource files. There can be only one main function in these files. When a beginner writes a simple program, a project often has only one CPP file. The Workspace (workspace) is a collection of project. When debugging a complex program, a workspace may contain multiple project, but for a beginner's simple program, a workspace often contains only one project.
When you finish a program, before you write another program, be sure to select the "Close Workspace" item in the "File" menu and completely shut down the previous item before you can proceed to the next project. One way to avoid this error is to completely turn off the VC6 every time you finish writing a C + + program, and then rewrite the VC6 to write the next program.