Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Unresolved external error: LNK2001

Unresolved external error: LNK2001

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crushinghellhammer
    wrote on last edited by
    #1

    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!

    M 1 Reply Last reply
    0
    • C crushinghellhammer

      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!

      M Offline
      M Offline
      Mike K Clark
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups