Unresolved external error: LNK2001
-
I'm porting code written in C++ for a Motorola ColdFire chip to Visual C++. In the original program I have two files which I will call Code.cpp and Code.h Code.h has the class and member function declarations and Code.cpp has member function definitions and the operative code. The main class for the program is, let's say, cMain, which has a bunch of nested classes. Now in my Code.cpp file, after the declarations of the constants, I had the following line extern cMain Main; In Visual C++ (VS2003) this throws an LNK2001 error. If I remove the extern the program compiles without error. Could somebody please explain why this is so? When should an object be instantiated using "extern" in VC++ (VS2003)? Thanks!
-
I'm porting code written in C++ for a Motorola ColdFire chip to Visual C++. In the original program I have two files which I will call Code.cpp and Code.h Code.h has the class and member function declarations and Code.cpp has member function definitions and the operative code. The main class for the program is, let's say, cMain, which has a bunch of nested classes. Now in my Code.cpp file, after the declarations of the constants, I had the following line extern cMain Main; In Visual C++ (VS2003) this throws an LNK2001 error. If I remove the extern the program compiles without error. Could somebody please explain why this is so? When should an object be instantiated using "extern" in VC++ (VS2003)? Thanks!
Linker Tools Error LNK2001 When your writing code you have to label the functions, variables, classes, etc... If you label something that it cannot find or is listed twice you will receive an LNK2001 process error. If that doesn't work try this on the main menu of Visual C++ go to project settings, and click on the C/C++ tab. remove _ATL_MIN_CRT from the preprocessor definitions, although depending on what version of Visual C you are running it may automatically be removed. Most likely however their is a function or variable that is listed twice in the Class tree, which again is causing compilation errors. Although if this doesn't work try looking at the error itself at msdn. Here is the link feel free to email me if you have any more questions or are still receiving problems -Mike