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. error LNK2001: unresolved external symbol "public: __

error LNK2001: unresolved external symbol "public: __

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++questiondebuggingtutorial
9 Posts 3 Posters 2 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.
  • B Offline
    B Offline
    BrockVnm
    wrote on last edited by
    #1

    Ok, so this is starting to get really annoying. Everytime I write some code and I want to go back to it after I turn my pc off I get this error. I tried using the answer to question 2.7 in the debuging questions article and that did not work....I am really confused why this is happening and I have no idea how to fix it. It is really starting to slow me down :(( Can anyone help me with this?? I have gotten these errors with every MFC program I am writing! Here are the files I'm using. main.cpp radio.h radio.cpp Here is the errors. --------------------Configuration: main - Win32 Debug-------------------- Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::~Radio(void)" (??1Radio@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Radio::Display(int)" (?Display@Radio@@QAEXH@Z) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::Radio(void)" (??0Radio@@QAE@XZ) Debug/main.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. main.exe - 4 error(s), 0 warning(s) Please help?????? Thanks everyone!!!!! :confused:

    A 1 Reply Last reply
    0
    • B BrockVnm

      Ok, so this is starting to get really annoying. Everytime I write some code and I want to go back to it after I turn my pc off I get this error. I tried using the answer to question 2.7 in the debuging questions article and that did not work....I am really confused why this is happening and I have no idea how to fix it. It is really starting to slow me down :(( Can anyone help me with this?? I have gotten these errors with every MFC program I am writing! Here are the files I'm using. main.cpp radio.h radio.cpp Here is the errors. --------------------Configuration: main - Win32 Debug-------------------- Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::~Radio(void)" (??1Radio@@QAE@XZ) main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Radio::Display(int)" (?Display@Radio@@QAEXH@Z) main.obj : error LNK2001: unresolved external symbol "public: __thiscall Radio::Radio(void)" (??0Radio@@QAE@XZ) Debug/main.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. main.exe - 4 error(s), 0 warning(s) Please help?????? Thanks everyone!!!!! :confused:

      A Offline
      A Offline
      Amit Dey
      wrote on last edited by
      #2

      Try including radio.h and radio.cpp before main.cpp - this error usually occurs when the linker cannot resolve the definitions for the Radio class.

      Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
      Writing Word addins Office addin

      B 1 Reply Last reply
      0
      • A Amit Dey

        Try including radio.h and radio.cpp before main.cpp - this error usually occurs when the linker cannot resolve the definitions for the Radio class.

        Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
        Writing Word addins Office addin

        B Offline
        B Offline
        BrockVnm
        wrote on last edited by
        #3

        Maybe I am not getting this right because I am new to this, but what do you mean? I have main.cpp which looks like this: #include #include #include "Radio.h" int main() { Radio x; //x is the object called. It is of class type Radio int Number = 7; x.Display(Number); return 0; } Radio.cpp is the definitions of Radio.h. Main.cpp is the main program....I dont understand what you mean??

        A 1 Reply Last reply
        0
        • B BrockVnm

          Maybe I am not getting this right because I am new to this, but what do you mean? I have main.cpp which looks like this: #include #include #include "Radio.h" int main() { Radio x; //x is the object called. It is of class type Radio int Number = 7; x.Display(Number); return 0; } Radio.cpp is the definitions of Radio.h. Main.cpp is the main program....I dont understand what you mean??

          A Offline
          A Offline
          Amit Dey
          wrote on last edited by
          #4

          #include "Radio.cpp" or add the cpp file to the project and rebuild.

          Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
          Writing Word addins Office addin

          B 1 Reply Last reply
          0
          • A Amit Dey

            #include "Radio.cpp" or add the cpp file to the project and rebuild.

            Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
            Writing Word addins Office addin

            B Offline
            B Offline
            BrockVnm
            wrote on last edited by
            #5

            Ok, that works! But I have another quick question. I have not had to do this before when compiling C++ projects and I also do not have to do it when I create the project from scratch (I only got this problem when I continued working on a project after I turned my PC off). In both my C++ book and my MFC book they only include the hearder.h file. How come in the books they do not include the header.cpp file? Is this something I am going to have to do with all MFC and C++ projects in the future? Thank you for your help Kula, this has really been helpful!

            A 1 Reply Last reply
            0
            • B BrockVnm

              Ok, that works! But I have another quick question. I have not had to do this before when compiling C++ projects and I also do not have to do it when I create the project from scratch (I only got this problem when I continued working on a project after I turned my PC off). In both my C++ book and my MFC book they only include the hearder.h file. How come in the books they do not include the header.cpp file? Is this something I am going to have to do with all MFC and C++ projects in the future? Thank you for your help Kula, this has really been helpful!

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              #include "radio.h" into radio.cpp and then #include "radio.h" into main.cpp That should work!

              B 1 Reply Last reply
              0
              • A Anonymous

                #include "radio.h" into radio.cpp and then #include "radio.h" into main.cpp That should work!

                B Offline
                B Offline
                BrockVnm
                wrote on last edited by
                #7

                I have that and it didnt work :((

                A 1 Reply Last reply
                0
                • B BrockVnm

                  I have that and it didnt work :((

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #8

                  I'm not sure what compiler you're using, however I use Visual C++ 6.0. When I create a new Win32/Console application and define a new class I simply insert the header file for the class into main.cpp and everything compiles and links just fine. From what I gather of your original post, it sounds like a compiler configuration issue. You might want to consult Microsoft's Knowledge Base just to find out if this is a known issue and if so, how to fix the problem. I hope this helps. :)

                  B 1 Reply Last reply
                  0
                  • A Anonymous

                    I'm not sure what compiler you're using, however I use Visual C++ 6.0. When I create a new Win32/Console application and define a new class I simply insert the header file for the class into main.cpp and everything compiles and links just fine. From what I gather of your original post, it sounds like a compiler configuration issue. You might want to consult Microsoft's Knowledge Base just to find out if this is a known issue and if so, how to fix the problem. I hope this helps. :)

                    B Offline
                    B Offline
                    BrockVnm
                    wrote on last edited by
                    #9

                    I had to readd the files to my workspace for some odd reason. Thanks for all of your help! :-D

                    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