This guide is designed to help you interpret some of the more common (or more unusual) error messages that you may run into as you compile and link your programs. It will not necessarily tell you how to fix the errors, but serves more as a blueprint to help you interpret the messages you receive and locate the actual problems.
| Generator | Error Message | Tip |
|---|---|---|
| Editor | The normal color highlighting on your source code (green for comments, blue for keywords, etc.)has changed to something else. | You may have used File->Save As to directly save your skeleton program from the lab manual as you were viewing it in the web browser. You should absolutely avoid doing this, as the file will be saved read-only, with a .htm file extension. This will make it impossible for the compiler to properly recognize the file when you get ready to compile it. It is also possible that some evil person has been messing around with the program settings. Do not curse them, simply select View->Properties and select C/C++ language instead of whatever they selected. |
| Compiler | Any syntax error indicating a missing ";" | Look backwards from the line indicated and you will usually (though not always) quickly see the actual problem. If the error occurs in a for statement, make sure that the three sections of the for statement control are separated by semicolons and not commas. |
| Compiler | Identifiers defined in libraries are showing up as undefined, but you have included the library. | You probably forgot to include the statement "using namespace std;" after the included libraries. |
| Compiler | Error message indicates that you are missing a semicolon before the 'PCH' point. This error message will generally appear right before the using namespace std; statement. | The problem is probably a missing semicolon at the end of a user-defined header file. Check all your header files and make sure they are correct -- remember, they can't be compiled separately so this is the only way you have of checking them. |
| Linker | Error indicates that external symbol "WinMain16" is missing | You inadvertently created a Windows application instead of a Windows Console Application. Close this project and create a new, empty, one, making sure that this new one is a Windows Console Application. Once this new project is created, add the files you were working on to the new project. |
| Debug or Run-time | Debug or run-time error with the message:
Debug Error!
Program |
This is a bug in the Standard C++ library basic_string class implementation.
It is NOT REALLY YOUR FAULT.
It is caused by assigning a shorter string value to an existing string variable that originally contained a longer string value.
This causes corruption of the heap.
You can work around this error by calling the string::erase member function before assigning the new value to the string: yourstring.erase( ); yourstring = "new string value"; |
| Linker | LNK2001 errors | There are a number of possible causes for this type of error. The most common is that you have created a project with a driver file, but not added any non-standard included files (header and/or implementation files) to the project. To fix this error, click on Project->Add to Project->Files and add the missing files to the project |
| Linker | LNK4076 error | The .ilk file in your project's debug folder is corrupted. It doesn't matter how it happened, it just did. Go into the Debug folder for your project, delete the .ilk file, and rebuild the project. |