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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Link error: LNK 2001 unresolved symbol

Link error: LNK 2001 unresolved symbol

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiohelpcsharpcomdebugging
5 Posts 3 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.
  • P Offline
    P Offline
    PCuong1983
    wrote on last edited by
    #1

    Sorry all about pre-my post Here is my source code: http://www.in4site.com/hms.txt When i run compiler i got this error Error 1 error LNK2001: unresolved external symbol "private: static class std::list > * Hotel::_rooms" (?_rooms@Hotel@@0PAV?$list@VRoom@@V?$allocator@VRoom@@@std@@@std@@A) HSM.obj Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\Google\Documents\Visual Studio 2005\Projects\HMSv10\Debug\HMSv10.exe i have looked up LNK2001 error code on MSDN website but no solution for this situation. Can any1 help me solve it ? but when i use vs 2005 to compile i got LNK2001 error, but when i use vs 2008 to compile , i got no error, this program run normally ? i dont know why ? can any1 answer this ? thanks in advance

    T C 2 Replies Last reply
    0
    • P PCuong1983

      Sorry all about pre-my post Here is my source code: http://www.in4site.com/hms.txt When i run compiler i got this error Error 1 error LNK2001: unresolved external symbol "private: static class std::list > * Hotel::_rooms" (?_rooms@Hotel@@0PAV?$list@VRoom@@V?$allocator@VRoom@@@std@@@std@@A) HSM.obj Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\Google\Documents\Visual Studio 2005\Projects\HMSv10\Debug\HMSv10.exe i have looked up LNK2001 error code on MSDN website but no solution for this situation. Can any1 help me solve it ? but when i use vs 2005 to compile i got LNK2001 error, but when i use vs 2008 to compile , i got no error, this program run normally ? i dont know why ? can any1 answer this ? thanks in advance

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      Member 2428381 wrote:

      have looked up LNK2001 error code on MSDN website but no solution for this situation

      I don't know what you saw there, and what you tried to fix that out, but :

      unresolved external symbol "private: static class std::list > * Hotel::_rooms"

      means that the compiler knows the definition of your class (in its .h file most probably), but the implementation is not foundin the directoried the linker is searching into. do you have the implementation file somewhere else ? is it an external library ? if so, you certainly missed to had its path in the linker settings of your project...

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      P 1 Reply Last reply
      0
      • P PCuong1983

        Sorry all about pre-my post Here is my source code: http://www.in4site.com/hms.txt When i run compiler i got this error Error 1 error LNK2001: unresolved external symbol "private: static class std::list > * Hotel::_rooms" (?_rooms@Hotel@@0PAV?$list@VRoom@@V?$allocator@VRoom@@@std@@@std@@A) HSM.obj Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\Google\Documents\Visual Studio 2005\Projects\HMSv10\Debug\HMSv10.exe i have looked up LNK2001 error code on MSDN website but no solution for this situation. Can any1 help me solve it ? but when i use vs 2005 to compile i got LNK2001 error, but when i use vs 2008 to compile , i got no error, this program run normally ? i dont know why ? can any1 answer this ? thanks in advance

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Looking at the code you posted earlier, Hotel::_rooms is a std::list (I don't know a list of what because the < and > symbols were treated as html tags and disappeared). I'm not sure, but it looks like it is a pointer also. Is that what you want instead of just having a list object ? Anyway, as I asked in my previous post, static variables need to be defined in a cpp file. Do you have something like this:

        std::list<...;>* Hotel::_rooms = NULL;

        in your cpp file ?

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        P 1 Reply Last reply
        0
        • T toxcct

          Member 2428381 wrote:

          have looked up LNK2001 error code on MSDN website but no solution for this situation

          I don't know what you saw there, and what you tried to fix that out, but :

          unresolved external symbol "private: static class std::list > * Hotel::_rooms"

          means that the compiler knows the definition of your class (in its .h file most probably), but the implementation is not foundin the directoried the linker is searching into. do you have the implementation file somewhere else ? is it an external library ? if so, you certainly missed to had its path in the linker settings of your project...

          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          P Offline
          P Offline
          PCuong1983
          wrote on last edited by
          #4

          Hi, I just combinated all code into once file as you saw at http://www.in4iste.com/hms.txt But when i use vs 2005 to compile i got LNK2001 error and when i use vs 2008 to compile , i got no error, this program run normally. im a new in c++, please help!

          1 Reply Last reply
          0
          • C Cedric Moonen

            Looking at the code you posted earlier, Hotel::_rooms is a std::list (I don't know a list of what because the < and > symbols were treated as html tags and disappeared). I'm not sure, but it looks like it is a pointer also. Is that what you want instead of just having a list object ? Anyway, as I asked in my previous post, static variables need to be defined in a cpp file. Do you have something like this:

            std::list<...;>* Hotel::_rooms = NULL;

            in your cpp file ?

            Cédric Moonen Software developer
            Charting control [v1.5] OpenGL game tutorial in C++

            P Offline
            P Offline
            PCuong1983
            wrote on last edited by
            #5

            Yeah, the full code of that: std::list Hotel::_rooms = NULL; but when i put that line into my cpp file, i got "Project : error PRJ0002 : Error result 31 returned from 'c:\Program Files\Microsoft Visual Studio 8\VC\bin\mt.exe" I have used the "No (/INCREMENTAL:NO)" link option to solved this error Thanks You!

            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